posted 15 years ago
Hi,
For option C to be correct we need munch(Plant p) method instead of munch(Grass x)!
Because when you replace E with Plant in Interface Herbivore, method's signature would become
void munch(Plant p);
But in the implementation of Sheep, method is overloaded as Grass is used as input parameter instead of Plant.
Since there is no implementation given in Sheep for munch(Plant x), code wont compile!
For this code to compile, either Sheep class has to be abstract or we have to add implementation for method munch(Plant x).
Hope you get it!