It prints 0 as expected. now if i change void print() at line1 to private void print() or static void print().. it prints A200 as expected since method now cannot be overloaded. how does java implement all this ?
[ March 27, 2005: Message edited by: Aruna Agrawal ] [ March 27, 2005: Message edited by: Aruna Agrawal ]
[Aruna]: now if i change void print() at line1 to private void print()
As you might be aware that if the print method is private in the parent class A200, then it is not visible to the derived class A100. So there is no question of overriding in this case. The only print method the ctor of class A200 is aware is it's own print method. Hence you get the output as A200.
[Aruna]: now if i change void print() at line1 to static void print()..
This won't compile. Static methods cannot be overridden. However you can hide them in the derived class.
Hope I tried to be as clear as possible this time.
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.