On page 108 of the K&S book, they gave the following example
I previously read that when overriding a method, the new method can throw fewer or narrower (sub-type) exception.
The above two examples seem valid i.e. both calls on line 13 and line 14 are correct because the new method does not throw any exceptions (i.e the overriden method throws fewer exceptions).
Why does the compiler reject the call on line 14 then?
Even though Animal a is actually a Dog right now, the compiler knows that "a" could end up pointing at a regular Animal at some point in the program. If that happens, you will have to be ready to catch the potential exception.
As the compiler knows only about the references and not about the object hold by those references at the compile time so compiler checks whether the Animal class has a method named eat.
Yes it does.
So the compiler is happy to see that but compiler says wait a minute a could see an Exception that is neither handled nor declared and this upsets the compiler.
So you must either handle or declare that main throws an exception and then the compiler will be happy