What is the correct syntax to declare a class named 'MyClass' in Kotlin?
class MyClass()
object MyClass
class MyClass {}
public class MyClass
How can you check if a value is within a range in Kotlin?
None of the above
Using the 'in' operator
Both 'in' operator and 'contains' method can be used
Using the 'contains' method
What is the primary constructor in Kotlin?
The constructor defined within the class header.
Kotlin doesn't have constructors.
A constructor declared inside the class body.
A constructor declared using the 'constructor' keyword.
What is the difference between a MutableSet and an ImmutableSet in Kotlin?
MutableSets allow duplicate elements, while ImmutableSets do not.
MutableSets are ordered, while ImmutableSets are unordered.
MutableSets can be modified after creation, while ImmutableSets cannot.
There is no difference; both are interchangeable.
What is a field in Kotlin?
A static variable
A constant value
A property declared inside a function
A backing field for a property
What is the size of the array declared in this Kotlin code?
val fruits = arrayOf("apple", "banana")
2
1
3
0
What is the correct way to print 'Hello, World!' to the console in Kotlin?
System.out.println("Hello, World!")
println("Hello, World!")
console.log("Hello, World!")
print("Hello, World!")
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)
What is the primary advantage of using arrays over lists in Kotlin?
Arrays can store different data types.
Arrays are dynamically sized.
Arrays offer better performance for certain operations.
Arrays are immutable.
Which code snippet creates an immutable list of strings in Kotlin?
val names = listOf("Alice", "Bob", "Charlie")
val names = setOf("Alice", "Bob", "Charlie")
val names = mutableListOf("Alice", "Bob", "Charlie")
val names = arrayListOf("Alice", "Bob", "Charlie")