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

With this sealed hierarchy, is the `when` exhaustive without an `else` branch, and why?

sealed interface Shape data class Circle(val r: Double) : Shape data class Square(val s: Double) : Shape fun area(shape: Shape): Double = when (shape) { is Circle -> Math.PI * shape.r * shape.r is Square -> shape.s * shape.s }