015-005-003
instanceof Operator: Type Checking
Medium
Problem Description
In this problem, you will create a program that instantiates an animal object (Dog, Cat, or Bird) based on the input string, uses the instanceof operator to determine its type, and displays the type name and flying capability to standard output.
instanceof operator: Type Checking
Learning Objective: Check object type using instanceof operator
Check animal object type with instanceof and perform type-specific processing.
Input
1 line: Animal type (dog, cat, bird)
Output
Type: [type name]
Can fly: [Yes/No]
Example
Input:
bird
Output:
Type: Bird
Can fly: Yes
Test Cases
※ Output examples follow programming industry standards
Input:
bird
Expected Output:
Type: Bird Can fly: Yes
Input:
dog
Expected Output:
Type: Dog Can fly: No
Input:
cat
Expected Output:
Type: Cat Can fly: No
Input:
unknown_action
Expected Output:
Type: Bird Can fly: Yes
❌ Some tests failed
Your Solution
Current Mode:● My Code
Animal.java🔒
Dog.java🔒
Cat.java🔒
Bird.java🔒
Main.java🔒
5/6 ファイル257B
⚠️警告
- No main method found
9
1
2
3
4
›
⌄
import java.util.Scanner;
class Animal {
}
0 B / 5 MB
You have 3 free executions remaining
