Which keyword is used to declare a class in Kotlin?
class
object
struct
interface
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
Which data structure is best suited for storing a collection of unique elements in Kotlin?
Map
Array
List
Set
How do you call a method named 'myMethod' on an object 'myObject' in Kotlin?
myObject->myMethod()
myMethod(myObject)
myObject.myMethod()
call(myObject, myMethod)
What is the difference between emptyList() and mutableListOf() in Kotlin?
emptyList()
mutableListOf()
emptyList() creates a list with a fixed size, while mutableListOf() creates a list with dynamic size.
There is no difference; both are interchangeable.
emptyList() is used for numbers, while mutableListOf() is used for strings.
emptyList() creates an empty immutable list, while mutableListOf() creates an empty mutable list.
What will be printed after executing the following Kotlin code?
for (i in 1..3) { println(i * 2) }
123
1 2 3
246
2 4 6
What is the primary difference between listOf() and mutableListOf() in Kotlin?
listOf()
listOf() creates an immutable list, while mutableListOf() creates a mutable list.
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.
Which keyword makes a variable immutable in Kotlin?
final
val
let
const
What is the output of listOf(1, 2, 2, 3).toSet() in Kotlin?
listOf(1, 2, 2, 3).toSet()
{1, 2, 3}
{1, 2, 2, 3}
[1, 2, 2, 3]
[1, 2, 3]
Which of the following is NOT a valid way to declare an immutable list in Kotlin?
listOf("apple", "banana", "cherry")
mutableListOf("apple", "banana", "cherry")
listOf<String>("apple", "banana", "cherry")
emptyList<String>().plus("apple").plus("banana").plus("cherry")