// INHERIT9a class A { public int x; // Class B won't be able to "see" the following constructor! private A() { System.out.println("Hi!");} // So, use protected or a public constructor that accesses the // private constructor: public A(int x) { this(); this.x=x; } } class B extends A { public B(int x) { super(x); System.out.println("x: "+x); } } public class inherit9a { public static void main(String[] args) { new B(2); } } /* output: Hi! x: 2 */