What is a data class in Kotlin?
A class for database interactions.
A class that cannot be instantiated.
A class that holds only constants.
A class designed to primarily hold data and provides automatically generated utility functions.
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 push() function
push()
Using the append() function
append()
Using the add() function
add()
Which of the following is NOT a characteristic of a Kotlin List?
Provides indexed access to elements.
Allows duplicate elements.
Can store elements of different data types.
Maintains the order of elements.
What is the output of listOf(1, 2, 2, 3).toSet() in Kotlin?
listOf(1, 2, 2, 3).toSet()
{1, 2, 2, 3}
[1, 2, 2, 3]
[1, 2, 3]
{1, 2, 3}
Which of the following is NOT an advantage of Kotlin?
Null safety
More verbose than Java
Concise syntax
Interoperable with Java
How do you check if a specific key exists in a Kotlin map?
containsKey()
hasKey()
keyExists()
findKey()
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 is the difference between a MutableSet and an ImmutableSet in Kotlin?
MutableSets can be modified after creation, while ImmutableSets cannot.
MutableSets are ordered, while ImmutableSets are unordered.
MutableSets allow duplicate elements, while ImmutableSets do not.
There is no difference; both are interchangeable.
Which code snippet creates an immutable list of strings in Kotlin?
val names = arrayListOf("Alice", "Bob", "Charlie")
val names = setOf("Alice", "Bob", "Charlie")
val names = listOf("Alice", "Bob", "Charlie")
val names = mutableListOf("Alice", "Bob", "Charlie")
Which keyword makes a variable immutable in Kotlin?
val
final
let
const