What is the output of listOf(1, 2, 2, 3).toSet() in Kotlin?
listOf(1, 2, 2, 3).toSet()
{1, 2, 3}
[1, 2, 3]
[1, 2, 2, 3]
{1, 2, 2, 3}
What is a data class in Kotlin?
A class for database interactions.
A class designed to primarily hold data and provides automatically generated utility functions.
A class that holds only constants.
A class that cannot be instantiated.
What is the size of the array declared in this Kotlin code?
val fruits = arrayOf("apple", "banana")
3
0
1
2
What is the correct way to print 'Hello, World!' to the console in Kotlin?
console.log("Hello, World!")
print("Hello, World!")
System.out.println("Hello, World!")
println("Hello, World!")
How do you pass a lambda expression as an argument to a function in Kotlin?
By enclosing the lambda expression in parentheses.
By simply passing the lambda expression without any special syntax.
By using the 'function' keyword before the lambda expression.
Lambda expressions cannot be passed as arguments in Kotlin.
What is the correct syntax to declare a class named 'MyClass' in Kotlin?
public class MyClass
object MyClass
class MyClass {}
class MyClass()
How do you access the element at index 2 in a Kotlin array named 'numbers'?
numbers[2]
numbers.elementAt(2)
numbers.get(2)
numbers.indexOf(2)
How do you create an instance of a class named 'MyClass' in Kotlin?
MyClass myClass = new MyClass()
MyClass myClass
var myClass = new MyClass()
val myClass = MyClass()
What is the output of the following Kotlin code?
val numbers = setOf(1, 2, 2, 3) println(numbers.size)
4
Error
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