015-002-006
Polymorphism: Array Management
Medium
Problem Description
Polymorphism: Array Management
Learning Objective: Understand how to manage different subclass objects using a parent class array
Overview
You have Dog and Cat classes that inherit from Animal class. Store different animals in an Animal-type array and output each animal's sound.
Specifications
- Animal class:
makeSound()method (empty implementation) - Dog class:
makeSound()outputs "Woof!" - Cat class:
makeSound()outputs "Meow!" - Store Dog, Cat in Animal-type array
- Call
makeSound()for all animals in loop
Output Format
Woof!
Meow!
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
