What is the output of the following Kotlin code: 'println(2 + 3 * 4)'?
10
Error
14
20
How do you access the element at index 2 in a Kotlin array named 'numbers'?
numbers.elementAt(2)
numbers.indexOf(2)
numbers.get(2)
numbers[2]
What is the output of the following Kotlin code?
val numbers = setOf(1, 2, 2, 3) println(numbers.size)
3
1
4
Which of the following is NOT a valid way to declare an immutable list in Kotlin?
listOf("apple", "banana", "cherry")
listOf<String>("apple", "banana", "cherry")
mutableListOf("apple", "banana", "cherry")
emptyList<String>().plus("apple").plus("banana").plus("cherry")
What is the correct syntax to declare a class named 'MyClass' in Kotlin?
object MyClass
public class MyClass
class MyClass {}
class MyClass()
How do you create an instance of a class named 'MyClass' in Kotlin?
MyClass myClass
val myClass = MyClass()
MyClass myClass = new MyClass()
var myClass = new MyClass()
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 add() function
add()
Using the append() function
append()
What is the output of the following code?
for (i in 1..5) { if (i == 3) continue println(i) }
1245
12345
1234
124
How do you define a secondary constructor in Kotlin?
You can't define multiple constructors in Kotlin.
By using the 'override' keyword before the constructor declaration.
Using the 'secondary' keyword before the constructor declaration.
By defining another constructor inside the class body using the 'constructor' keyword.
Which method adds an element to the end of a mutable list in Kotlin?
insert()