LearnFrenzy
Sign in Take a free test

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

valueOf with an unknown name Answer, explanation & discussion

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

What does Size.valueOf("XL") do if there is no XL constant?

  • A Returns null
  • B Throws IllegalArgumentException Correct
  • C Returns the first constant
  • D Creates a new constant
Correct Answer: Option B

valueOf is also case-sensitive.

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