Please put your code in the code tags. Makes things easier for me .
When instantiating A, the compiler is so kind and puts 'super()' as the first statement in the constructor. You got that part correct.
Now, the B constructor calls 'call()', which is polymorphically (since you instantiated A) delegated to the concrete class, so the B constructor calls 'call()' on the A class.
The value 0 goes to the output since instance variables get initialized after the super constructor ran, hence b is still 0.
JDBCSupport - An easy to use, light-weight JDBC framework -
Apart from the fact that calling methods from the constructor can be dangerous (unless they are labelled "private" or "final") . . .
What you have here is an example of polymorphism. You create an A and it invokes the "A" version of the method. That demonstrates that calling method from the constructor can be dangerous; you don't know what they are going to do.
Joined: Jun 04, 2009
Thanks a lot to both of you guys for clearing this confusion.