ExamVeda
Login
Home
71
What is the difference between a and b?
var a: String? = "KotlinProgramming"
var b: String = 'KotlinProgramming"
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
72
Which is true for the following simple class declaration?
class Person (val name: String)
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
73
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()
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
74
The code below is expected to display the numbers from 1 to 10, but it does not. Why?
val seq = sequence { yieldAll(1..20) }
  .filter { it < 11 }
  println(seq)
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
75
You have an unordered list of high scores. Which is the simple method to sort the highScores in descending order?
fun main() { val highScores = listOf(4000, 2000, 10200, 12000, 9030)}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
76
What three methods does this class have?
class Person
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
77
In this code snippet, why does the compiler not allow the value of y to change?
for(y in 1..100) y+=2
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
78
Both const and @JvmField create constants. What can const do that @JvmField cannot?
class Detail {
  companion object {
    const val COLOR = "Blue"
    @JvmField val SIZE = "Really Big"
  }
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
79
You have two arrays, a and b. Which line combines a and b as a list containing the contents of both?
val a = arrayOf(1, 2, 3) val b = arrayOf(100, 200, 3000)
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
80
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
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board