C. A class can have final static methods.
Yes, a class can have final static methods. The final modifier means that the method cannot be overridden in subclasses, and the static modifier means that the method belongs to the class itself, not to instances of the class.
D. A class can have overloaded private constructors.
Yes, a class can have overloaded private constructors. Overloading means having multiple constructors with different parameter lists. Private constructors restrict instantiation outside the class but allow overloading.
E. Fields need to be initialized before use.
Yes, fields in Java need to be initialized before they are used. If they are not explicitly initialized, they will be assigned default values (for example, 0 for numeric types, null for reference types).
The incorrect statements are:
A. A class cannot have the same name as its field.
This statement is incorrect. A class can have a field with the same name as the class itself, although it's not recommended for clarity.
B. A public class must have a main method.
This statement is incorrect. While a class with a public static void main(String[] args) method is required to be the entry point for a Java application, not all public classes need to have a main method.
F. Methods and fields are optional components of a class.
This statement is incorrect. In Java, a class must have at least one constructor (which can be the default constructor) and can contain methods and fields, but a class must have a constructor to initialize its instances.
A, B, D, F are like what iSnover said.
C is correct as static and final are not the oppositve. abstract and final are opposite. Final just means the method / class cannot be inherited further, and static method means the method is available to use without initializing any objects of the class.
E is wrong as fields can be uninitialized. They remain at their default values. (char --> \u0000, boolean --> false, short / int / long / float / double --> numerical 0 in their own types, String / Object --> null)
The correct answer is DEF:
A -> Wrong, a class can have the same name as its field.
B -> Wrong, a public class doesn't need to have a main method, you can create empty public class.
C -> Wrong, you can't have static and final methods, you can only put one of the 2 because final doesn't allow changes
D -> Correct, a class can overload private constructors, just extend the other class and use the same view (private) or greater.
E -> Correct, Fields need to be initialized before use, as Java is a typed language.
F -> Correct, as I said before, you can create an empty class.
C is wrong?
literally open any online java compiler, add 'final' to the main method, see if it will work or not (it works btw)
upvoted 1 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.
MPignaProTech
2 months, 3 weeks agodsms
1 year, 4 months agodsms
1 year, 5 months agodsms
1 year, 5 months agosina_
1 year, 5 months agoakbiyik
2 years, 1 month agocarloswork
2 years, 2 months agoUAK94
2 years, 3 months agoalex_au
2 years, 3 months agoiSnover
2 years, 3 months agoyanoolthecool
1 year ago