new B () calls constructor B, which calls constructor A. The constructor calls printDate() , which, because of the redefinition, executes B printDate() , which prints the value of the variable d B However, the variable d B is not yet initialized (it will be initialized only after the execution of constructor A). Therefore, it is still null (this is the default value for reference variables).
On the other hand, when you instantiate A ( new A() ), printDate of A is printDate , and it prints the variable d A , which was initialized earlier to the executable constructor A
If this is not clear, Bd does not override Ad, it just hides it. Only methods can be overridden.
source share