Kevin Florish wrote:
Actually it calls the eat method of Cat, because with overrides the actual object type of Cat is dynamically called at runtime, not the reference type of Animal
Thanks, Kevin.
By the way, let me do it again.
Thread t actually overrides the run method that prints "Dog", like Animal a = new Cat(); a.eat(); This eat() is the Cat's eat(), not its parent's eat.
Why r's run() is not called? If your Cat class has an attribute , such as int claw that Animal class does not have, Animal class knows nothing about that Cat's claw.
The same thing here: