1Z0-808 practice question 2 of 30
Which three statements are true about the structure of a Java class? (Choose three.)
Full set: 224 questions--- QUESTION #97 --- Which three statements are true about the structure of a Java class? (Choose three.)
Correct Answer: C, D, F
Explanation:
(C) A method can have the same name as a field because they exist in different namespaces within the class.
(D) Static methods can be overloaded, just like instance methods, by defining multiple static methods with the same name but different parameter lists.
(F) Class fields (static variables) and instance fields are automatically initialized with default values (e.g., 0 for numeric types, null for object references) if not explicitly initialized. Local variables, by contrast, must be initialized. Why Incorrect Options are Wrong: A: A class, even a public one, is not required to have a main method. Only the application entry-point class needs one. B: A class can have multiple overloaded private constructors, provided their parameter lists differ. E: Methods are not mandatory. A class can be legally defined with only fields, or even be completely empty.
References: Oracle, The Java™ Tutorials. "Initializing Fields." "If a primitive type... is not initialized, it has a default value." Gosling, J., Joy, B., Steele, G., & Bracha, G. (2014). The Java™ Language Specification, Java SE 8 Edition. Section 8.4.9, "Overloading". This section applies to all methods, including static ones. Gosling, J., Joy, B., Steele, G., & Bracha, G. (2014). The Java™ Language Specification, Java SE 8 Edition. Section 6.3, "Scope of a Declaration". This section details the different namespaces for types, fields, and methods.
Keep practicing
Take the free 1Z0-808 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 1Z0-808 practice questions
- Question 3Which three statements are true about exception handling? (Choose three.)
- Question 9Which two are benefits of polymorphism? (Choose two.)
- Question 15Which statement is true about the switch statement?
- Question 28Which statement is true about the main() method?
- Question 29Given the class definitions: class C1 {} class C2 extends C1 {} class C3 extends C2 {} an…
