Solved

Consider the Following Class Definition

Question 39

Multiple Choice

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)
B) Only (ii)
C) Only (iii)
D) Both (ii) and (iii)

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions