Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis In Microsoft Excel

Authors: Alex Holloway

1st Edition

B0CCCPKTTX, 979-8852388452

More Books

Students also viewed these Databases questions

Question

=+b) What would the data values in such an indicator variable be?

Answered: 1 week ago

Question

1. Describe the factors that lead to productive conflict

Answered: 1 week ago