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:
Verified
Q28: Consider the following class definition. public class
Q29: A mutator method of a class changes
Q30: Which of the following class definitions is
Q31: In _ copying, each reference variable refers
Q32: Consider the following statements. public class Circle
Q34: Which of the following is used to
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents