Kotlin Basic QuizBy Parvesh Sandila / September 15, 2023 Welcome to your Kotlin Basic Questions Name Email 1. Given the following Kotlin program, what will be the value of result? val x = 5val y = 3val result = x * y 53 8 3 15 None 2. What is the entry point of a Kotlin program? run() method execute() function main() function start() function None 3. How do you declare a nullable variable in Kotlin? Using the # symbol Using the ? operator Using the * symbol Using the ! operator None 4. What is the range operator used to create a range of numbers in Kotlin? .. -> -- :: None 5. In Kotlin, which collection type represents an ordered list of elements? Array List Map Set None 6. What is the output of the following Kotlin program? fun main() { var sum = 0 for (i in 1..10) { sum += i } println(sum) } 45 55 10 15 None 7. What is the output of the following Kotlin program? fun main() { var a = 5 var b = 10 a = b.also { b = a } println("After swapping: a = $a, b = $b")} After swapping: a = 0, b = 0 This program will not compile. After swapping: a = 5, b = 10 After swapping: a = 10, b = 5 None 8. Which Kotlin feature helps prevent null pointer exceptions? Elvis operator (?:) Unicorn operator (->>) Star operator (*) Arrow operator (->) None 9. In Kotlin, which keyword is used to declare a variable that cannot be reassigned? const let val var None 10. What does the following Kotlin program do? fun main() { var n = 10 var factorial = 1 while (n > 0) { factorial *= n n-- } println(factorial)} Prints the first 10 prime numbers. Calculates the sum of the first 10 numbers. Calculates the factorial of 10. Prints the numbers from 10 to 1 in reverse order. None 11. What is the Kotlin equivalent of a "for loop" in other programming languages? repeat loop foreach loop while loop for-in loop None 12. In Kotlin, what is the purpose of the "fun" keyword? It stands for "funny" It declares a function It specifies a variable's data type It defines a new data type None 13. 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)} 10 3 120 15 None 14. How can you define a read-only property in Kotlin? Using the "readonly" keyword Using the "val" keyword Using the "get" keyword Using the "var" keyword None 15. In Kotlin, what keyword is used to declare a function? fun method func proc None 1 out of 15