How do you exit a loop prematurely in Kotlin?
Using the 'continue' keyword
Using the 'return' keyword
All of the above
Using the 'break' keyword
What is the default visibility modifier for classes and members in Kotlin?
public
private
protected
internal
What is the primary difference between listOf() and mutableListOf() in Kotlin?
listOf()
mutableListOf()
There is no difference; both functions are interchangeable.
listOf() creates a list of integers, while mutableListOf() creates a list of strings.
listOf() creates a fixed-size list, while mutableListOf() creates a dynamically sized list.
listOf() creates an immutable list, while mutableListOf() creates a mutable list.
What is the purpose of single-line comments in Kotlin?
To declare variables
To import external libraries
To define code blocks
To add explanations or disable code temporarily
What is the output of the following Kotlin code?
val numbers = setOf(1, 2, 2, 3) println(numbers.size)
3
4
1
Error
What will be printed after executing the following Kotlin code?
for (i in 1..3) { println(i * 2) }
2 4 6
1 2 3
123
246
How do you check if a specific key exists in a Kotlin map?
hasKey()
findKey()
containsKey()
keyExists()
Which data structure is best suited for storing a collection of unique elements in Kotlin?
List
Map
Set
Array
How do you declare a variable in Kotlin with a String value 'Hello'?
string greeting = 'Hello'
var greeting = 'Hello'
var greeting: String = "Hello"
val greeting = "Hello"
What is the correct way to create a range of integers from 1 to 5 (inclusive) in Kotlin?
1..5
[1, 2, 3, 4, 5]
1 to 5
range(1, 5)