ExamVeda
Login
Home
61
What is the type of arr in the following code?
val arr = arrayof(1, 2, 3)
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
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()")
  }
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
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++
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
64
This code does not print any output to the console. What is wrong?
firstName?.let {
  println("Greeting $firstname!")
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
65
What is the equivalent of the following Java expression in Kotlin?
int x = a ? b : c 
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
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 }
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
67
What is the output of the following code?
val list : List<Int> = listof(1, 2, 3)
list.add(4)
print(list)
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
68
What does the following code print?
val listA = mutableListOf(1, 2, 3)
val listB = listA.add(4)
print(listB)
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
69
What is the difference between the declarations of COLOR and SIZE?
class Record{
  companion object {
    const val COLOR = "Red"
    val SIZE = "Large"
  }
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
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(_____)
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board