LearnFrenzy
Sign in Take a free test

Records, Enums and Sealed Classes · Records, Enums and Sealed Classes MCQ · Question 8

The enum singleton Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

Why is enum Config { INSTANCE; } considered the safest singleton?

  • A It is faster
  • B The JVM guarantees a single instance, even under serialization and reflection, with thread-safe initialisation Correct
  • C It can be subclassed
  • D It is lazily created on every call
Correct Answer: Option B

Recommended by Effective Java.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links