posted 16 years ago
Hello ranchers,
Here this code:
Outputs:
Mammal eats food
My first question is: Is eat() being overridden or overloaded? Arguments in subclasses are subclasses of those argument defined in superclasses.
I understand that c.eat(h) attaches it to mammal's version at compile time because of reference variable, but at runtime doesn't it know that the object held is of type horse. Since class Cattle doen't have eat(horse), it should have invoked eat(cattle).
Thanks in advance
Deepak