1.
In Kotlin, what is the purpose of the "fun" keyword?
2.
In Kotlin, which keyword is used to declare a variable that cannot be reassigned?
3.
Given the following Kotlin program, what will be the value of max?
val num1 = 10
val num2 = 25
val num3 = 15
val max = if (num1 >= num2 && num1 >= num3) num1
else if (num2 >= num1 && num2 >= num3) num2
else num3
4.
What is the output of the following Kotlin program?
fun main() {
var sum = 0
for (i in 1..10) {
sum += i
}
println(sum)
}
5.
What is the range operator used to create a range of numbers in Kotlin?
6.
What does the following Kotlin program do?
fun main() {
var n = 10
var factorial = 1
while (n > 0) {
factorial *= n
n--
}
println(factorial)
}
7.
What is the output of the following Kotlin program?
fun main() {
val numbers = arrayOf(1, 2, 3, 4, 5)
val sum = numbers.reduce { acc, num -> acc + num }
println(sum)
}
8.
What is the Kotlin equivalent of a "for loop" in other programming languages?
9.
In Kotlin, what keyword is used to declare a function?
10.
In Kotlin, which collection type represents an ordered list of elements?
11.
How can you define a read-only property in Kotlin?
12.
Given the following Kotlin program, what will be the value of result?
val x = 5
val y = 3
val result = x * y
13.
What is the entry point of a Kotlin program?
14.
How do you declare a nullable variable in Kotlin?
15.
Which Kotlin feature helps prevent null pointer exceptions?