Examveda

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

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


This Question Belongs to Computer Science >> Kotlin Program

Join The Discussion

Related Questions on Kotlin Program

What is Kotlin?

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.