Question: Create an abstract class called Animal , Include instance variables for name and sound , Include an abstract method makeSound ( ) , Include a

Create an abstract class calledAnimal, Include instance variables fornameandsound, Include an abstract methodmakeSound(), Include a concrete methodgetName()that returns the animal's name. Create a subclass classDogthat extendsAnimaland overridesmakeSound()to print "Woof!". Create a subclass classCatthat extendsAnimaland overridesmakeSound()to print "Meow!". Create instances ofDogandCat. Store them in an array of typeAnimal. Loop through the array and callmakeSound()on each animal.

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 Programming Questions!