1. As you do the steps, but sure to fill in the < your answer here> parts... Also, be sure to do them IN ORDER.

2.There is a class called Rectangle for this Minilab. It defines a geometric rectangle - open it and look at it to see if it makes sense.

3.Now that you have a Rectangle class to work with, the following 3 statements should work. Run the MinilabInheritance program and check the results.

4.Go back to the Rectangle class and change it so that its data can be INHERITED by subclasses (but still cannot be seen or changed from another class).

5.There is a class called Square for this Minilab. It will basically be a blank class. Change it so that it is a SUBCLASS of Rectangle. (Do not give it ANY data - it should be able to inherit from its parent class.)

6.Write a constructor for your Square class. The constructor should receive a SINGLE double which will be the length of each side. Since it has (inherited) data of length and width, set the length AND the width to what is passed in (or... it can call the superclass's constructor with the single int that it has)

7.Uncomment the following 2 statements, recompile, and run this program. Then finish the Question in the S.O.P. below, and run again.

8.Now go to your Square class and "override" the inherited toString() method by writing a specific toString() method for Square. Have it return "I am a Square with sides = < either the length or the width here>"

9.Uncomment the following 2 statements, and run this program. Then finish the Question in the S.O.P. below, and run again.

10. Uncomment the following statement. Then run. Then finish the Question in the S.O.P. below, and run again.

11. Be SURE that you have filled in the parts (like directly above). Also, be sure that you understand the results - basically, Square is a special case of Rectangle so it can be a subclass. This allows it to inherit data/methods as well as have its own.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.