Oracle Certified Professional Java Se 8 Programmer · Free Practice Question Hard

Question 25

Consider the code of Test.java file:

What will be the result of compiling and executing Test class?

  • A

    HELLO is printed twice

  • B

    None of the other options

  • C

    Exception is thrown at runtime

  • D

    HELLO is printed once

Reveal correct answer

Correct answer: A

Explanation

Enum constructor is invoked once for every constant.


For 'Flags.TRUE', enum constructor is invoked for TRUE as well as FALSE.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need