What is the difference between a MutableSet and an ImmutableSet in Kotlin?
There is no difference; both are interchangeable.
MutableSets are ordered, while ImmutableSets are unordered.
MutableSets can be modified after creation, while ImmutableSets cannot.
MutableSets allow duplicate elements, while ImmutableSets do not.
What is the output of the following Kotlin code?
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]
Error
10
What will be printed after executing the following Kotlin code?
for (i in 1..3) { println(i * 2) }
123
1 2 3
2 4 6
246
What are the two types of properties in Kotlin?
Public and private
Stored and computed
Constant and variable
Static and dynamic
How can you check if a value is within a range in Kotlin?
None of the above
Using the 'contains' method
Using the 'in' operator
Both 'in' operator and 'contains' method can be used
What is a data class in Kotlin?
A class that cannot be instantiated.
A class for database interactions.
A class that holds only constants.
A class designed to primarily hold data and provides automatically generated utility functions.
What is the purpose of the 'when' statement in Kotlin?
To perform different actions based on different conditions
To declare a variable
To define a function
To execute a block of code repeatedly
How can you add an element to a mutable list in Kotlin?
You cannot add elements to a mutable list once it's created.
Using the add() function
add()
Using the push() function
push()
Using the append() function
append()
How do you use a named argument when calling a function in Kotlin?
By using the '->' symbol followed by the argument name and value.
By specifying the argument name followed by '=' and the value inside the function call.
By simply passing the values in the correct order.
Named arguments are not supported in Kotlin.
How do you define a function in Kotlin?
function myFunction() {}
void myFunction() {}
def myFunction() {}
fun myFunction() {}