Choose the correct statement
public class Circle{
private double radius;
public Circle(double radius){
radius = radius;
}
}
public class Circle{
private double radius;
public Circle(double radius){
radius = radius;
}
}
A. The program has a compilation error because it does not have a main method.
B. The program will compile, but we cannot create an object of Circle with a specified radius. The object will always have radius 0.
C. The program has a compilation error because we cannot assign radius to radius.
D. The program does not compile because Circle does not have a default constructor.
Answer: Option B
What is the default access modifier for class members in Java if no access modifier is specified?
A. public
B. protected
C. private
D. package-private
A. private
B. public
C. protected
D. package-private
What keyword is used to declare a constant in Java, which is implicitly final and static?
A. final
B. const
C. static
D. constant
A. protected
B. private
C. public
D. default
Join The Discussion