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 DEFAULTWIDTH with value of
Private Class constants DEFAULTHEIGHTS with value of
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 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
