Kotlin is a modern programming language. What is its main use?
Think about what Kotlin is famous for in mobile development.
Kotlin is mainly used to build Android apps and also for server-side programming. It is not used for styling websites, database management, or OS kernels.
Look at this Kotlin code and choose the correct output.
fun main() { val name = "Kotlin" println("Hello, $name!") }
Remember how string templates work in Kotlin.
The code uses a string template with $name, so it prints the value of the variable name inside the string.
Analyze the code and select the output it produces.
fun main() { val numbers = listOf(1, 2, 3, 4) val doubled = numbers.map { it * 2 } println(doubled) }
Think about what the map function does to each list item.
The map function applies the lambda to each element, doubling each number in the list.
Find the error this Kotlin code will cause when run.
fun main() { val x: Int = null println(x) }
Consider Kotlin's null safety rules for variables declared as Int.
Kotlin does not allow assigning null to a variable declared as non-nullable Int. This causes a compile-time type mismatch error.
Kotlin has a special feature to reduce errors from null values. What is it called?
Think about how Kotlin handles variables that can hold null values safely.
Kotlin uses nullable types (e.g., String?) and safe call operators (?.) to avoid null pointer exceptions at runtime.