Consider the following statements. public class Circle {private double radius; public Circle() {radius = 0.0;} public Circle(double r) {radius = r;} public void set(double r) {radius = r;} public void print() {System.out.println(radius + " " + area + " " + circumference) ;} public double area() {return 3.14 * radius * radius;} public double circumference() {return 2 * 3.14 * radius;}} Circle myCircle = new Circle() ; double r; Which of the following statements are valid in Java? (Assume that console is Scanner object initialized to the standard input device.) (i) r = console.nextDouble() ; myCircle.area = 3.14 * r * r; System.out.println(myCircle.area) ; (ii) r = console.nextDouble() ; myCircle.set(r) ; System.out.println(myCircle.area() ) ;
A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) None of these
Correct Answer:
Verified
Q27: Constructors have the same name as the
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
Q33: Consider the following class definition. public class
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