Question: Make the class Square below inherit from Rectangle Add a Square no - argument constructor that calls Rectangle s constructor using super ( ) .

Make the class Square below inherit from Rectangle
Add a Square no-argument constructor that calls Rectangles constructor using super().
Add a Square constructor with 1 argument for a side that calls Rectangles constructor with 2 arguments using super.
Uncomment the objects in the main method to test drawing the squares.
Add an area() method to Rectangle that computes the area of the rectangle. Does it work for squares too? Test it.
Add another subclass called LongRectangle which inherits from Rectangle but has the additional condition that the length is always 2 x the width. Write constructors for it and test it out.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!