Question 9
Back to Exercise
What happens when the selector of a classic switch (s) on a String is null?
- A default runs
- B NullPointerException Correct
- C The first case runs
- D Nothing
Correct Answer: Option B
Java 21 switches can add case null to handle it.
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!