In your program, Parent constructor calls the method() of Child class because 'child' refers to Child class object and the member variable of Child is not initialized at this time therefore null is output.
hope you got it.
Joined: Sep 01, 2006
Could anybody explain the flow of execution and how it prints Null
Joined: Aug 16, 2006
As I have told the flow goes as follows: 1. as Child class object gets crested, its constructor gets called. 2. In the body of Child constructor, before the execution of the first line, Parent constructor gets called. 3. as method() is overridden in Child class, child class object will call overridden method method(). 4. but the instance variable of Child class gets initialized just before the first line in the Child constructor is going to be executed(but it gets initilialized only after the completion of the Parent constructor )