Hi ranchers,
Can any one plz explain why the actual method called at runtime is the overriding method of Horse class.
Output of above code is:
In Horse Object A similar question is discussed in K & B book under the heading "Polymorphism in Overloaded and Overridden Methods" on page 109, but with slight difference. Instead of eat(Object) signature, the Animal class defines following signature...
public void eat(){...}
Code below....
This code is clear to me. Here at line 2, compilation error will come coz eat(
String) is not defined in Animal class. Whereas in my case, since eat(Object) is defined in Animal class and String can be promoted to Object so no compilation error will come in my code.
My question is why the overriding method called at runtime in first case.
Thanks
Naseem Khan
[ May 30, 2006: Message edited by: Naseem Khan ]