This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The Reference variable's type not the object's type determines which method can be called and polymorphic method invocation apply only to overridden method. Thats why this code
runs eat() method of Horse.
As eat() method is an overridden method and Polymorphism applies to overriding so object's type( here Horse) method runs.
Here the reference type is Animal which doesn't have buck() method so it will not compile. buck() is not an overridden method but an instance method of Horse. Calling of method is determined at compile time based on reference type