Which three statements are true about the structure of a Java class? (Choose three.)
Which three statements are true about the structure of a Java class? (Choose three.)
A method can indeed have the same name as a field within a class. A class can have overloaded static methods, meaning the same method name can be used but with different parameters. Fields in a class do not need to be initialized before use; they will take default values if not explicitly initialized.
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.
Don't agree with D. Static methods can't be overwritten, they can only be hidden. There are only 2 right answers here imo
It says overloaded, not overwritten. It's not the same.
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
Sorry, CDF is correct
CDF IS THE CORRECT
CDF are correct
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 }
CDF Question #96 is an example for D