Question: Given the code below public class Rectangle { private double length; private double width; // setters and getters public double getLength(){???} public void setLength(???){???} public

Given the code below

public class Rectangle {

private double length;

private double width;

// setters and getters

public double getLength(){???}

public void setLength(???){???}

public double getWidth(){???}

public void setWidth(???){???}

// object method

????calculateArea(){????}

????isSquare(){????}

}

a. Complete the appropriate Getter methods.

b. Complete the appropriate Setter methods - including the parameters required

c. Complete a method so that the method calledcalculateArea() returns the area of the rectangle.

d. Complete a method so that the method calledisSquare() returns true if width is equal to length, otherwise return false.

e. Create an object obj and set its length as 10 and width as 7. Print its area and tell if it is a square.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Getter methods public double getLength return length public do... View full answer

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!