Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions