Asked by Laila Mohamed on Mar 10, 2024



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.)
R = console.nextDouble() ;
MyCircle.area = 3.14 * r * r;
System.out.println(myCircle.area) ;
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

Scanner Object

A Scanner object in Java is used to read input from various sources, including user input from the console.


A method used in Java to read the next floating-point number input from the console.


A geometric figure consisting of all points in a plane that are at a given distance (radius) from a given point (the center).

  • Grasp the essentials of object-oriented programming, which entails classes, methods (public and private), constructors, and objects.

Verified Answer

McKennah Mullen

Mar 10, 2024

Final Answer :
Explanation :
(i) is invalid because the variable name should be in lowercase and you cannot directly access instance variables from outside the class.

(ii) is valid because it sets the radius using the set method and prints the area using the area method. However, the variable name should be in lowercase.