abstract class A {
private int a;
public A(int x) {
a = x;
}
public int getA() {
return a;
}
}
class B extends A {
public B(int x) {
super(x);
}
}
class TestB {
public static void main(String args[]) {
B b = new B(5);
System.out.println(b.getA());
}
}
In this situation when i say B b=new B(5); the super class constructor is called and the private instance variable is initialized to 5. So when i say getA() on class B's object reffered by b it returns 5. As the instance variable a of class A is private it will not be inherited by the class B . So where does the instance variable a is created(on heap) . Had it been a public it would have been a part of class B instance on Heap. Also class A is an abstarct class so it can not be instantiated.