When the Airplane class is instantiated, it displays Aircraft = null, not Aircraft = C130 why?
abstract class Aircraft {
init { println("Aircraft = ${getName()}") }
abstract fun getName(): String
}
class Airplane(private val name: String) : Aircraft() {
override fun getName(): String = name
}
abstract class Aircraft {
init { println("Aircraft = ${getName()}") }
abstract fun getName(): String
}
class Airplane(private val name: String) : Aircraft() {
override fun getName(): String = name
}A. Classes are initialized in the same order they are in the file, therefore, Aircraft should appear after Airplane
B. The code needs to pass the parameter to the base class's primary constructor. Since it does not, it receives a null
C. Abstract function always returns null
D. A superclass is initialized before its subclass. Therefore, name has not been set before it is rendered
Answer: Option C
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