015-001-003
Basic Polymorphism: Shape Class
Easy
Problem Description
Basic Polymorphism: Shape Class
Learning Objective: Understand polymorphism handling child class objects with parent class reference
Create Shape class representing shapes, Circle and Rectangle classes inheriting from it. Handle child class objects with parent class reference and learn that overridden methods are called.
Input
Line 1: Shape type ("Circle" or "Rectangle")
Line 2: Size (integer)
Output
Shape Type: [Circle/Rectangle]
Size: [size]
Area: [area]
Test Cases
※ Output examples follow programming industry standards
Input:
Circle 5
Expected Output:
Shape Type: Circle Size: 5 Area: 78.5
Input:
Rectangle 4
Expected Output:
Shape Type: Rectangle Size: 4 Area: 16.0
Input:
Circle 1
Expected Output:
Shape Type: Circle Size: 1 Area: 3.14
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 9 free executions remaining
