62.
From the Supervisor subclass, how do you call the Employee class's display() method?
open class Employee(){
  open fun display() = println("Employee display()")
}
class Supervisor : Employee() {
  override fun display() {
    println("Supervisor display()")
  }
}

63.
The code below shows a typical way to show both index and value in many languages, including Kotlin. Which line of code shows a way to get both index and value more idiomatically?
var ndx = 0;
for (value in 1..5){
  println("$ndx - $value")
  ndx++
}

64.
This code does not print any output to the console. What is wrong?
firstName?.let {
  println("Greeting $firstname!")
}

66.
You have an enum class Signal that represents the state of a network connection. You want to print the position number of the SENDING enum. Which line of code does that?
enum class Signal { OPEN, CLOSED, SENDING }

67.
What is the output of the following code?
val list : List<Int> = listof(1, 2, 3)
list.add(4)
print(list)

69.
What is the difference between the declarations of COLOR and SIZE?
class Record{
  companion object {
    const val COLOR = "Red"
    val SIZE = "Large"
  }
}

70.
In the file main.kt, you ae filtering a list of integers and want to use an already existing function, removeBadValues. What is the proper way to invoke the function from filter in the line below?
val list2 = (80..100).toList().filter(_____)

Read More Section(Kotlin Program)

Each Section contains maximum 100 MCQs question on Kotlin Program. To get more questions visit other sections.