Question: Create a Rectangle class with length and width variables. Supply a constructor, toString ( ) , and getArea ( ) , and getPerimeter ( )
Create a Rectangle class with length and width variables. Supply a constructor, toString and getArea and getPerimeter methods.
Implement a Square class that inherits from Rectangle class. Supply a constructor, toString The inherited getArea and getPerimeter methods should work fine.
Create an array of Rectangle type to use Polymorphism and populate it with some Rectangles and some Squares. Use an enhanced for loop to print the areas of objects in the array
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
