dilan alex wrote:
The result of the above code is 'null'. I cannot understand why it results a null.
Can anyone explain >>
The order of instantiation is... The super() part of the constructor is executed. The instance variables (and instance initializers) are initialized in order that they were defined in the class. And finally, the rest of the constructor is executed.
This means.... the instance variable for the BB class has not been instantiated at the time the constructor for AA is called.
So.... when the AA constructor calls the method1() method, which due to
polymorphism, calls the method1() method of the BB class, the instance variables of the BB class has not been initialized yet.
Henry