Given: interface Hungry { void munch(E x); } interface Carnivore extends Hungry {} interface Herbivore extends Hungry {} abstract class Plant {} class Grass extends Plant {} abstract class Animal {} class Sheep extends Animal implements Herbivore { public void munch(Sheep x) {} } class Wolf extends Animal implements Carnivore { public void munch(Sheep x) {} } Which of the following changes (taken separately) would allow this code to compile? (Choose all that apply.)

  1. Change the Carnivore interface to interface Carnivore extends Hungry {}

  2. Change the Herbivore interface to interface Herbivore extends Hungry {}

  3. Change the Sheep class to class Sheep extends Animal implements Herbivore { public void munch(Grass x) {} }

  4. Change the Sheep class to class Sheep extends Plant implements Carnivore { public void munch(Wolf x) {} }

  5. Change the Wolf class to class Wolf extends Animal implements Herbivore { public void munch(Grass x) {} }

  6. No changes are necessary


Correct Option: B

Find more quizzes: