Question: Define a base class Animal with the following attributes and methods: Attributes: name ( String ) Methods: makeSound ( ) : Prints Generic Sound. Now,

Define a base class Animal with the following attributes and methods:
Attributes: name (String)
Methods: makeSound(): Prints Generic Sound.
Now, create two subclasses, Bird and Fish, that inherit from the Animal class.
For each subclass, override the makeSound() method to provide a unique sound for each type of animal. Additionally, add specific methods related to the characteristics of each type:
- For Bird: Add a method fly(): Prints Bird is Flying
- For Fish: Add a method swim(): Prints Fish is swimming
Define an abstract class EndangeredAnimal that extends the Animal class. This class should have an additional attribute endangered Level (String), representing the conservation status of the animal (e.g., "Critical," "Endangered," "Vulnerable").
Create two concrete classes, EndangeredBird and EndangeredFish, that extend the EndangeredAnimal class. Now, define an interface called Conservable with a method raise Awareness(). Make these two concrete classes this interface.
The raiseAwareness() method should print a message to raise awareness about the conservation status of the animal, i.e., 'Make a reserved forest for the Vulnerable Bird' or 'Make a reserved lake for the Critical Fish.
In the main file,
Create instances of EndangeredBird & Endangeredfish and show their awareness message.
Create an instance of Animal, Bird, and Fish each. Print the activities of Bird and Fish. Now, create an array of Animals named Zoo and add these three instances to the array.
Define a method called zoo Party(Animal []) that will print the sound of all the animals present in the array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!