Question: Instructions Develop a class called Rectangle with the following members: Private Class constants DEFAULT _ WIDTH with value of 5 Private Class constants DEFAULT _

Instructions
Develop a class called Rectangle with the following members:
Private Class constants DEFAULT_WIDTH with value of 5
Private Class constants DEFAULT_HEIGHTS with value of 5
Private Instance Variables width, length, area
Public method initRect that takes as input a width and height and sets the corresponding member values to these valuesthe method returns nothing
Public method computeArea that computes area and saves it as the variable area
Public method getArea that returns the area of the object
Public method setWidth that sets the width of the object to the corresponding value supplied by the input parameter
Public method setLength that sets the length of the object to the corresponding value supplied by the input parameter
Provide the body of a main program that would perform the following:
Creates an object of the class Rectangle called r
Initializes the object with a value of 5 for width and the content of the variable y as length
Computes the area of r
Gets the area of the object and displays it to the user via the System.out command

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 Databases Questions!