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()
}
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
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
Join The Discussion