posted 20 years ago
I understand that by extending Parent, Child inherits "method2()". When the method is called in main("p.method2()"), I understand that at run-time it is determined by the JVM that the underlying object which p refers to (of type Child) has its "method2()" called. Standard polymorphic call.
Once the inherited "method2()" starts executing, and the call to "method1()" is made, what I don't understand is why "method1()" from the Parent class is used instead of "method1()" from the Child class. Can anybody shed some light on why the result of this code was the following:
Parent's method2()
Parent's method1()
I was expecting this:
Parent's method2
Child's method1
Thanks,
Cliff
[ January 09, 2004: Message edited by: Cliff DeRose ]