014-005-001

Method Overriding: Animal Sounds

Easy

Problem Description

Method Overriding: Animal Sounds

Learning Objective: Redefine parent method in child class with @Override

Create Animal class representing animals and Dog/Cat classes inheriting from it. Override parent's speak() method in child classes to output different sounds.

Input

None (fixed output)

Output

Dog says: Woof!
Cat says: Meow!
```java

## Examples

### Example 1: Basic overriding
Input:
```java
(none)
```java
Output:
```java
Dog says: Woof!
Cat says: Meow!
```java

### How Overriding Works
- Define speak() method in parent class Animal
- Redefine speak() with @Override in child class Dog
- Similarly redefine in child class Cat
- When calling speak() on each instance, the respective child class implementation executes.

Test Cases

※ Output examples follow programming industry standards

Input:
Expected Output:
Input:
Expected Output:
Input:
Expected Output:
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
Animal.java🔒
Dog.java🔒
Cat.java🔒
Solution.java🔒
4/6 ファイル0B
⚠️警告
  • No main method found

0 B / 5 MB

You have 9 free executions remaining