Correct is CDF, A and E are wrong because you can create empty classes without problems. You can overload static methods (D) and The fields not necessarily need be ubutialized before use.
CDF is correct. Below is code.
package exam_javase1;
public class ClassBehavior {
//can have overloaded static methods
static int proof() {
return 1;
}
static int proof(int a) {
return a;
}
//can have method name same as variable name
int sum;
int sum() {
//fields not necessarily needs to be initialed before use
return sum+=1;
}
//can have multiple private constructor
private ClassBehavior() {
}
private ClassBehavior(int a) {
}
void methodA() {
System.out.println("Inside A");
}
//No main method required
}
Answer is BCD:
A. A public class must have a main method. - FALSE
B. A class can have only one private constructor. - TRUE
C. A method can have the same name as a field. - TRUE
D. A class can have overloaded static methods. - TRUE
E. The methods are mandatory components of a class. - FALSE
F. The fields need not be initialized before use. - FALSE
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
iSnover
Highly Voted 2 years, 3 months agoBramagon
1 year, 7 months agoHarch
9 months, 3 weeks agoMPignaProTech
Most Recent 2 months agofvelazqueznava
1 year, 3 months agoDarGrin
1 year, 3 months agoAlok1105
1 year, 4 months agodsms
1 year, 5 months agodsms
1 year, 4 months agotuyetan
1 year, 7 months ago