Study 1Z0-831 Java 25 Patterns, switch, and Branch Legality: key concepts, common traps, and exam decision cues.
Modern Java branch questions punish hand-waving. The winning move is still to decide legality first, then flow, then output.
| If the stem is mainly about… | Better first instinct |
|---|---|
| switch expression result | confirm every reachable path yields a value |
| pattern variable use | confirm the pattern actually matched in that control path |
| preview pattern features | check feature status before assuming baseline legality |
| “obvious” runtime output | decide legality first |
| Trap | Better rule |
|---|---|
| assuming any pattern variable is in scope everywhere after the test | scope follows the actual matched flow |
forgetting yield in block-style switch expressions |
result production is explicit |
| assuming modern switch behaves like older fall-through intuition | expression rules are stricter |