LearnFrenzy
Sign in Take a free test

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

When permits can be left out Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 20 Back to Exercise

When may the permits clause of a sealed class be omitted?

  • A Never
  • B When all permitted subclasses are declared in the same source file Correct
  • C When there is only one subclass
  • D When the class is abstract
Correct Answer: Option B

The compiler infers the permitted subclasses from the file.

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