Solved

Consider the Following Statements.public Class Circle

Question 45

Multiple Choice

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:

verifed

Verified

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

Related Questions