[CODE]
class SuperClassA {
protected int superValue;
public SuperClassA() {
System.out.println("Constructor in super classA");
this.doValue();
}
public void doValue() {
this.superValue = 911;
System.out.println("SuperValue: " + this.superValue);
}
}
class SubClassB extends SuperClassA {
private int value = 800;
public SubClassB() {
System.out.println("Constructor in SubClass B");
this.doValue();
System.out.println("SuperValue: " + this.superValue);
}
public void doValue() {
System.out.println("Value: " + this.value); // doubt ???
}
}
public class ObjectInitialization {
public static void main(
String[] args) {
new SubClassB();
}
}
{/CODE]
I have a doubt where I place "doubt ???". This line prints 800. As I understand the instance variable gets initialized after the base constructor completes the execution. In that case how is it printing 800 before the constructor completes?
Thanks