Question: Practicing adding Constructors, over write and overload the Object. On this assignment, reopen assignment 4.1 add the following to Rectangle class: 1) over right the

 Practicing adding Constructors, over write and overload the Object. On this

Practicing adding Constructors, over write and overload the Object. On this assignment, reopen assignment 4.1 add the following to Rectangle class: 1) over right the java Default Constructor with this Rectangle(){:} 2) overload the Rectangle class with this constructor Rectangle(double length, double width ) 3) overload the public methods with following two methods: void setLength(double length){ this.length=length; } void setLength(double length, double width}{ this.length=length; this.width=width; } Hint- 1 package rectangledemo; 2 public class Rectangle { 3 private double length; 4 private double width; Rectangle() {...} 6 Rectangle (double length, double width) {...4 lines } .0 # void setLength (double length) {...3 lines } 3 void setLength (double length, double width) {...4 lines } .7 # void setWidth (double width) {...3 lines } double getLength() { 2 double getWidth() { return width; 14 } 15 double getArea() { 16 return width * length; } :8 public void display() { System.out.println("W="+ width+ " L="+length+" Area="+getArea()); } } |

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!