USING JAVA Write these: An interface called Shape that has two methods: area and perimeter. A class Rectangle that implements Shape and has a length and a width. A class Circle that implements Shape and has a radius. For each class, write the needed constructors, getters, setters, and a toString method that stringifies the instance variables in a readable format. Supply a test program that instantiates an instance of each class and exercises each method defined for the class.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
USING JAVA
Write these:
- An interface called Shape that has two methods: area and perimeter.
- A class Rectangle that implements Shape and has a length and a width.
- A class Circle that implements Shape and has a radius.
For each class, write the needed constructors, getters, setters, and a toString method that stringifies the instance variables in a readable format.
Supply a test program that instantiates an instance of each class and exercises each method defined for the class.
First we have to create an interface name shape Which has 2 mwthod Area and perimeter.
Than we have create a class Rectangle That will implement Shape and it has a length and width.
last clas is circle that implement shape and has radius.
Step by step
Solved in 3 steps