Polymorphism Basics: Animal Class
Problem Description
polymorphism Basics: Animal class
In this problem, you will create a program that implements polymorphism by creating Dog and Cat classes that extend Animal, assigns child class objects to an Animal type variable, calls overridden getType() and getSound() methods, and displays the result to standard output.
Learning Objective: Understand polymorphism handling child class objects with parent class reference
Create an Animal class and Dog/Cat subclasses that inherit from it. Read the animal type ("Dog" or "Cat") and name from input, assign the child class object to an Animal type variable, and verify that the overridden methods are called correctly.
Input
Line 1: Animal type ("Dog" or "Cat")
Line 2: Name (string)
Output
Animal: [name]
Type: [Dog/Cat]
Sound: [Woof/Meow]
```java
## Examples
### Example 1: Dog case
Input:
```java
Dog
Pochi
```java
Output:
```java
Animal: Pochi
Type: Dog
Sound: Woof
```java
### Example 2: Cat case
Input:
```java
Cat
Tama
```java
Output:
```java
Animal: Tama
Type: Cat
Sound: Meow
```java
### Example 3: Boundary (single character name)
Input:
```java
Dog
A
```java
Output:
```java
Animal: A
Type: Dog
Sound: Woof
Test Cases
※ Output examples follow programming industry standards
Dog Pochi
Animal: Pochi Type: Dog Sound: Woof
Cat Tama
Animal: Tama Type: Cat Sound: Meow
Dog A
Animal: A Type: Dog Sound: Woof
Dog Pochi
Animal: Pochi Type: Dog Sound: Woof
Your Solution
- No main method found
You have 7 free executions remaining
