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
Related Questions on Kotlin Program
A. A new version of Java.
B. A JavaScript framework.
C. A statically-typed programming language for the JVM, Android, and browser.
D. A database management system.
Which platform does Kotlin primarily target?
A. Python Bytecode
B. JavaScript
C. JVM (Java Virtual Machine) Bytecode
D. PHP

Join The Discussion