016-001-010
Abstract Class Definition and Implementation
Hard
Problem Description
abstract class Definition and Implementation
In this problem, you will create a program that defines an abstract class Shape, implements the area() method in concrete classes Circle and Rectangle, and displays the area of each shape to standard output.
Learning Objective: Understand the role of abstract classes and methods, and learn to implement them in concrete classes
Overview
Abstract classes cannot be directly instantiated. Abstract methods force implementation in subclasses.
Specifications
- Define abstract class Shape with abstract double area() and concrete method describe()
- Circle and Rectangle extend Shape and implement area()
- describe() displays shape name and area
Output Format
Circle: area = 78.54
Rectangle: area = 24.00
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up