Loading…
Loading…
Ten exam-style questions on type patterns in switch, when guards, dominance and branch order, exhaustive pattern switches, case null, sealed types and record patterns, with explanations.
Practice questions for the article Java Pattern Matching for switch: Type Patterns, when Guards, null and Record Patterns.
The questions follow Java 21 rules, as on the 1Z0-830 exam. For every pattern switch, check three things: whether each type is allowed, whether any label is dominated, and whether the switch is exhaustive. Aim for at least 8 out of 10 before moving on.
Quiz path: step 15. Take the quizzes in this order, after reading each article.
Previous quiz: switch Statements and switch Expressions (OCP 21)
10 questions · pass at 68%
Check your understanding; you see the answers and explanations after submitting.
Discussion
Sign in to ask a question or share what you learned.