And the answer:
Note that method print() is overridden in class B. Due to polymorphism,the method
to be executed is selected depending on the class of the actual object.
Here,when an object of class B is created,first A's constructor is called,which in
turn calls print(). Now, since the class of actual object is B, B's print() is
selected. At this point of time, variable i has not been initialized (because we are still
initializing A at this point),so its default value i.e. 0 is printed.
This happens because the method print() is non-private, hence polymorphic.
I need help understanding how is B's print() available in A's constructor? First line of class B constructor is super() so nothing of A (expect static) should exist at this point?
Thanks!