0
0
Kotlinprogramming~20 mins

What is Kotlin - Practice Questions & Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kotlin Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
What is Kotlin primarily used for?

Kotlin is a modern programming language. What is its main use?

ADesigning website layouts and styles
BManaging databases with SQL queries
CBuilding Android apps and server-side applications
DCreating operating system kernels
Attempts:
2 left
💡 Hint

Think about what Kotlin is famous for in mobile development.

Predict Output
intermediate
1:30remaining
What is the output of this Kotlin code?

Look at this Kotlin code and choose the correct output.

Kotlin
fun main() {
    val name = "Kotlin"
    println("Hello, $name!")
}
AHello, Kotlin!
BError: Variable not found
CHello, Kotlin
DHello, $name!
Attempts:
2 left
💡 Hint

Remember how string templates work in Kotlin.

Predict Output
advanced
1:30remaining
What does this Kotlin code print?

Analyze the code and select the output it produces.

Kotlin
fun main() {
    val numbers = listOf(1, 2, 3, 4)
    val doubled = numbers.map { it * 2 }
    println(doubled)
}
A[2, 4, 6, 8]
B[1, 2, 3, 4]
C[3, 6, 9, 12]
DError: map function not found
Attempts:
2 left
💡 Hint

Think about what the map function does to each list item.

🔧 Debug
advanced
1:30remaining
What error does this Kotlin code raise?

Find the error this Kotlin code will cause when run.

Kotlin
fun main() {
    val x: Int = null
    println(x)
}
ANo error, prints null
BNullPointerException at runtime
CSyntaxError: Missing semicolon
DType mismatch: Null can not be a value of a non-null type Int
Attempts:
2 left
💡 Hint

Consider Kotlin's null safety rules for variables declared as Int.

🧠 Conceptual
expert
2:00remaining
Which Kotlin feature helps avoid null pointer exceptions?

Kotlin has a special feature to reduce errors from null values. What is it called?

AAutomatic garbage collection
BNull safety with nullable types and safe calls
CManual memory management
DStatic typing without nulls
Attempts:
2 left
💡 Hint

Think about how Kotlin handles variables that can hold null values safely.