Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavapattern matching switch instanceofSingle-choice MCQ

A pattern-matching switch over a non-null sealed type has a case for every permitted subtype but no case null. What happens when the selector is null at runtime?

Shape sh = null; String d = switch (sh) { case Circle c -> "circle"; case Square s -> "square"; };