016-002-009

Implementing Abstract Methods

Medium

Problem Description

Implementing Abstract Methods

In this problem, you will create a program that implements abstract methods getArea() and describe() in Circle and Rectangle classes extending the abstract class Shape, and displays the area and description of each shape to standard output.

Learning Objective: Understand the relationship between abstract class/method definition and implementation

Overview

Abstract methods are declared with the abstract keyword and have no body. They must be implemented (overridden) in subclasses.

Specifications

  • Define abstract class Shape with abstract methods getArea() and describe()
  • Create Circle and Rectangle classes extending Shape, implementing abstract methods
  • Create objects and display area and description

Output Format

Circle: radius=5
Area: 78
Rectangle: 4x6
Area: 24

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