Consider the following class definition. public class Rectangle {private double length; private double width; public Rectangle() {length = 0; width = 0;} public Rectangle(double l, double w) {length = l;

Consider the following class definition. public class Rectangle {private double length; private double width; public Rectangle() {length = 0; width = 0;} public Rectangle(double l, double w) {length = l; width = w;} public void set(double l, double w) {length = l; width = w;} public void print() {System.out.println(length + ” ” + width);} public double area() {return length * width;} public double perimeter() {return 2 * length + 2 * width;}} Which of the following statements correctly instantiates the Rectangle object myRectangle? (i) myRectangle = new Rectangle(12.5, 6); (ii) Rectangle myRectangle = new Rectangle(12.5, 6); (iii) class Rectangle myRectangle = new Rectangle(12.5, 6);
A) Only (i)
C) Only (iii)
B) Only (ii)
D) Both (ii) and (iii)

Leave a Reply

Your email address will not be published.