IS-A relationship

To answer this question, refer to the preceding code, and you’ll notice that the interface Hunter is implemented only by class Carnivore. Class Cow doesn’t extend class Carnivore. So, Cow IS-A Hunter is incorrect. Similarly, you can refer to the preceding code to answer all the other options. Option 2 is incorrect because class Tiger doesn’t extend class Herbivore. Option 3 is correct because the interface Movable is implemented by class Animal, which is the base class of Herbivore, extended by class Cow. Option 4 is incorrect because you can’t traverse the hierarchy tree down to determine an IS-A relationship. Evaluate it like this: An Herbivore IS-A type of Animal with some additions or modifications because an Herbivore can modify (override) methods of class Animal and add new ones. But Animal IS-NOT-A Herbivore. Animal can also be a Carnivore.

If you can traverse up, from a derived class or interface to a base class or interface, following the connecting arrows (lined or dashed), the derived entity shares an IS-A relationship with the base entity.

Problem :

Last updated