015-005-002

Shape Type Identification

Easy

Problem Description

In this problem, you will create a program that defines a Shape base class with Circle and Rectangle subclasses, implements a static method that uses the instanceof operator to determine an object's type and return its class name, and displays the result to standard output.

Create a Shape base class, and Circle and Rectangle subclasses. Implement a static method getShapeName(Shape shape) that uses instanceof to return 'Circle', 'Rectangle', or 'Unknown Shape'.

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
Circle
Expected Output:
Circle
Normal case
Input:
Rectangle
Expected Output:
Rectangle

Your Solution

Current Mode: My Code
Shape.java🔒
Circle.java🔒
Rectangle.java🔒
ShapeIdentifier.java🔒
Main.java🔒
5/6 ファイル230B
public class Shape {
}
0 B / 5 MB

You have 10 free executions remaining