When the getEat() method is invoked, it simply invokes the eat() method. This invocation occurs in the Animal class, and thus, the eat() method must be resolved from there.
In the first case, both classes Animal and Horse declare one public method called eat(). Since these methods are public, the one in class Horse is said to override the one in class Animal. Thus, the invocation of method eat() in class Animal boils down to invoking the overriding method in class Horse. Hence, the output.
In the second case, the method eat() in class Animal is declared private, and thus, it
cannot be overridden (
JLS 8.4.6.1 Overriding (by Instance Methods)). This doesn't mean that class Horse is not allowed to declare a method called eat(), just that the method eat() in class Horse
does not override the method eat() in class Animal. When the method eat() is invoked in class Animal, the call will resolve to the private method in the same class since there is no overriding. See
JLS 15.12 Method Invocation Expressions for an in-depth explanation of the method resolution process. I have written an article (
JLS 15.12 in Plain English) that tried to make it easier to understand how the whole method resolution process works.