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. Posted solutions are meant to be 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 complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.