016-001-008
Basics of Abstract Classes and Methods
Easy
Problem Description
Basics of Abstract Classes and Methods
In this problem, you will create a program that defines an abstract class Shape with an abstract method describe(), implements it in Circle and Square subclasses, and displays the result to standard output.
Learning Objective: Understand defining abstract classes and implementing abstract methods in subclasses
Overview
Define an abstract method describe() in abstract class Shape and implement it in Circle and Square.
Specifications
- Define
abstract void describe()inabstract class Shape Circleextends Shape, describe() printsI am a circle.Squareextends Shape, describe() printsI am a square.- In main, assign Circle and Square to Shape variables and call describe()
Output Format
I am a circle.
I am a square.
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