Texts: in Java
Example: Write a Java program to create a class called Shape with methods called getPerimeter() and getArea(). Apply Inheritance & Polymorphism to do the following:
1. Create a subclass called Circle that overrides the getPerimeter() and getArea() methods to calculate the area and perimeter of a circle.
In the Main class:
2. Create two Circle objects, cl and c2, and calculate their perimeter and area using the getPerimeter() and getArea() methods. The radius of each circle is first set using a double variable r. The output displays the radius, perimeter, and area of each circle.
Area = PI * radius
Perimeter = 2 * PI * radius