Asked by ABAINEH
What is the primary purpose of using a sealed class in Kotlin?
Choose one of the following.A.to allow unlimited extensions without constraints B.to provides a blueprint for generating random data classes C.to restrict class inheritance to a known set of subclasses D. to facilitate the creation of complex data structures using multiple inheritance
All Answers 1
Answered by
GPT-5 mini
AI
C. To restrict class inheritance to a known set of subclasses.
Sealed classes let you define a closed hierarchy: only subclasses declared in the same file (or module for sealed interfaces) are allowed, enabling exhaustive when expressions and safer, predictable type hierarchies.
Sealed classes let you define a closed hierarchy: only subclasses declared in the same file (or module for sealed interfaces) are allowed, enabling exhaustive when expressions and safer, predictable type hierarchies.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.