Create an interface Animal with methods
- animalSound() – display animal sound in implemented class
- run() – display speed of the animal in implemented class
- type() – display type of animal either Herbivores or Carnivores (Herbivores are animals that eat only plants. Carnivores are animals that eat only meat)
Create 3 classes Tiger, Cow, and Goat. All these 3 classes implement the Animal interface.
Create 3 instances of type Animal and assign Tiger, Cow, and Goat reference.
Invoke all the 3 interface methods for each animal instances.
interface Animal:
class Tiger:
class Cow:
class Goat:
class Main:
need an explanation for this answer? contact us directly to get an explanation for this answer