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 methodgetNamethat returns the animal's name. Create a subclass classDogthat extendsAnimaland overridesmakeSoundto print "Woof!". Create a subclass classCatthat extendsAnimaland overridesmakeSoundto print "Meow!". Create instances ofDogandCat Store them in an array of typeAnimal Loop through the array and callmakeSoundon each animal.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
