Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlinsealed class hierarchiesSingle-choice MCQ

In a `when` over a sealed class used as an expression, when is the `else` branch unnecessary, and what makes this differ from a regular class hierarchy?

sealed class Shape class Circle : Shape() class Square : Shape() fun area(s: Shape): Int = when (s) { is Circle -> 1 is Square -> 2 }