What is the purpose of the 'when' statement in Kotlin?
To perform different actions based on different conditions
To execute a block of code repeatedly
To define a function
To declare a variable
What is the output of the following code?
for (i in 1..5) { if (i == 3) continue println(i) }
1245
1234
12345
124
How do you define a property in Kotlin?
Using 'property' keyword
Properties are automatically generated from constructor parameters
Using 'var' or 'val' keyword before the variable declaration
Using 'field' keyword
What happens when you try to access a non-existent key in a Kotlin map?
It throws an IndexOutOfBoundsException.
It returns a default value.
It returns null.
It throws a NullPointerException.
How do you use a named argument when calling a function in Kotlin?
Named arguments are not supported in Kotlin.
By simply passing the values in the correct order.
By specifying the argument name followed by '=' and the value inside the function call.
By using the '->' symbol followed by the argument name and value.
What is the output of the following Kotlin code?
fun main() { val result = add(3, 5) println(result) } fun add(a: Int, b: Int): Int = a + b
5
Error
3
8
Which method adds an element to a mutable list in Kotlin?
add()
append()
insert()
put()
Which loop in Kotlin guarantees that the loop body will execute at least once?
do-while loop
for-each loop
while loop
for loop
How can you add an element to a mutable list in Kotlin?
Using the append() function
Using the push() function
push()
Using the add() function
You cannot add elements to a mutable list once it's created.
How do you access the value associated with the key "name" in a Kotlin map named user?
user
user["name"]
user.getValue("name")
user.name
user.get("name")