Vidyalelo
Computer Science · Q273

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 273

Q273

The code below compiled and executed without issue before the addition of the line declaring errorStatus. Why does this line break the code? sealed class Status() object Error : Status() class Success : Status() fun main() var successStatus = Status.Success() var errorStatus = Status.Error()

A.
StatusError is an object, not a class and cannot be instantiated
Answer
B.
Only one instance of the class Status can be instantiated at a time
C.
Status.Error must be declared as an immutable type
D.
Status.Error is pribate to class and cannot be declared externally

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board