Q281
Open questionwhen (die) {
1 -> println("die is 1")
2 -> println("die is 2")
___ -> printlin("die is between 3 and 6")
else -> printlin("dies is unknown")
}Select an option to see the answer and solution.
Practice every MCQ with options. Use Show answers when you want the correct option and solution.
292
Questions
15/15
Page
Pick an option on a question to see the right answer and solution.
Q281
Open questionwhen (die) {
1 -> println("die is 1")
2 -> println("die is 2")
___ -> printlin("die is between 3 and 6")
else -> printlin("dies is unknown")
}Select an option to see the answer and solution.
Q282
Open questionclass Cat (name: String) {
fun greet() { println("Hello ${this.name}") }
}
fun main() {
val thunderCat = Cat("ThunderCat")
thunderCat.greet()
}Select an option to see the answer and solution.
Q283
Open questionfun main() {
val num = 15
when (num) {
10 -> println("Ten")
15 -> println("Fifteen")
20 -> println("Twenty")
else -> println("Other")
}
}Select an option to see the answer and solution.
Q284
Open questionfun main() {
val list = listOf(1, 2, 3, 4, 5)
for (num in list) {
println(num)
}
}Select an option to see the answer and solution.
Q285
Open questionval addend = 1
infix fun Int.add(added: Int=1) = this + addend
fun main(){
val msg = "Hello"
println( msg shouldMatch "Hello")
println( 10 multiply 5 + 2)
println( 10 add 5)
}Select an option to see the answer and solution.
Q286
Open questionval task = launch {
// long running job
}Select an option to see the answer and solution.
Q287
Open questionabstract class Person(val name: String) {
abstract fun displayJob(description: String)
}Select an option to see the answer and solution.
Q288
Open questionval test = 33 to 42Select an option to see the answer and solution.
Q289
Open questioninline fun simple(x: Int): Int{
return x * x
}
fun main() {
for(count in 1..1000) {
simple(count)
}
}Select an option to see the answer and solution.
Q290
Open questionVal result = generateSequence(1) { it + 1 }.toList(); Println(result)Select an option to see the answer and solution.
Q291
Open questionfun String.shouldEqual(value: String) = this == value
fun main(){
val msg = "test message"
println(msg shouldEqual "test message")
}Select an option to see the answer and solution.
Q292
Open questionfun fibonacci() = sequence {
var params = Pair(0, 1)
while (true) {
___(params.first)
params = Pair(params.second, params.first + params.second)
}
}Select an option to see the answer and solution.