What is the output of the following Kotlin code: 'println(2 + 3 * 4)'?
20
14
Error
10
What is a lambda expression in Kotlin?
A keyword used for error handling.
A way to define anonymous functions.
A special kind of variable.
A type of loop in Kotlin.
How do you access the element at index 2 in a Kotlin array named 'numbers'?
numbers[2]
numbers.elementAt(2)
numbers.get(2)
numbers.indexOf(2)
How do you read a line of input from the user in Kotlin?
readLine()
read()
scanner.nextLine()
input()
What is the output of the following Kotlin code snippet?
val x = 5 if (x > 10) { println("Greater than 10") } else if (x < 10) { println("Less than 10") } else { println("Equal to 10") }
Equal to 10
The code will not compile
Less than 10
Greater than 10
What is the output of the following Kotlin code?
val numbers = setOf(1, 2, 2, 3) println(numbers.size)
4
1
3
How do you check if a specific key exists in a Kotlin map?
findKey()
containsKey()
hasKey()
keyExists()
fun main() { greet(name = "Alice") } fun greet(greeting: String = "Hello", name: String) { println("$greeting, $name!") }
Hello, Alice!
Alice!
Hello,
What is a field in Kotlin?
A backing field for a property
A property declared inside a function
A constant value
A static variable
fun main() { val numbers = listOf(1, 2, 3, 4, 5) val doubled = numbers.map { it * 2 } println(doubled) }
[1, 2, 3, 4, 5]
[2, 4, 6, 8, 10]