exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 158 discussion

Actual exam question from Oracle's 1z0-808
Question #: 158
Topic #: 1
[All 1z0-808 Questions]

Which three statements are true about the structure of a Java class? (Choose three.)

  • A. A class cannot have the same name as its field.
  • B. A public class must have a main method.
  • C. A class can have final static methods.
  • D. A class can have overloaded private constructors.
  • E. Fields need to be initialized before use.
  • F. Methods and fields are optional components of a class.
Show Suggested Answer Hide Answer
Suggested Answer: CDF 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
MPignaProTech
2 months, 3 weeks ago
Selected Answer: CDF
CDF is the good answer
upvoted 1 times
...
dsms
1 year, 4 months ago
Selected Answer: CDF
sorry, I was wrong. The correct is CDF
upvoted 1 times
...
dsms
1 year, 5 months ago
Selected Answer: CDE
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).
upvoted 1 times
dsms
1 year, 5 months ago
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.
upvoted 1 times
...
...
sina_
1 year, 5 months ago
classs1{}//ok class ss{ int ss = 0;//ok private ss(){}//pl private ss(String s){}//ok final static void m1(){}//ok } so cdf
upvoted 1 times
...
akbiyik
2 years, 1 month ago
Selected Answer: CDF
Answer is CDF
upvoted 1 times
...
carloswork
2 years, 2 months ago
Selected Answer: CDF
Answer is CDF, Option E - Static fields and wrappers fields have default value. Do not need to be initialized.
upvoted 1 times
...
UAK94
2 years, 3 months ago
CDF is the answer. Classes can have final static methods (tested)
upvoted 1 times
...
alex_au
2 years, 3 months ago
Selected Answer: CDF
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)
upvoted 1 times
...
iSnover
2 years, 3 months ago
Selected Answer: DEF
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.
upvoted 1 times
yanoolthecool
1 year ago
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
...
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago