Question: QUESTION 5 What is wrong with the following code: class Circle { double radius; double diam; double area ( ) { return radius * radius

QUESTION 5
What is wrong with the following code:
class Circle{
double radius;
double diam;
double area(){ return radius * radius {:?**3.24;}
void diameter(){ diam= radius {:?**2;}
public static void main(String[] args){
Circle c= new Circle();
c.radius =2.1;
c.diameter();
System.out.println(c.area());
}
}
A. radius and diam are dependent, so one of them should me a method.
B. The method diameter should return double.
C. radius should be private.
D. The class has no constructor
QUESTION 6
What is the output of the following program
class X{
final int a;
x(){a=5;}
public static void main(String[] args){
xx=newx();
System.out.println("X.a ="+ x.a);
}
}
A. X.a=5;
B. X.a=0;
C. The program has error because a is not static.
D. The program has error because a should be initialized when it is declared.
 QUESTION 5 What is wrong with the following code: class Circle{

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!