What does this print?
val name: String? = nullprintln(name?.length ?: -1)
What this Kotlin test measures, in short
This test checks whether you can predict what real Kotlin does: how nullable types and ?: behave, what data classes generate, how == differs from ===, what each scope function returns, and how when, sealed classes and coroutines work.
Snippets assume Kotlin 2.0 on the JVM inside fun main. The questions are our own and not standardised against a population, so treat the result as a knowledge check, not a certification.
By What's Your IQ · Reviewed 4 Oct 2026- Format
- 15 predict-the-output questions, 4 options each
- Topics
- Null safety, classes and equality, collections and lambdas, scope functions, control flow and coroutines
- Version
- Kotlin 2.0, JVM
- Language
- Created by JetBrains; 1.0 in 2016
Five scope functions, two questions
let, run, with, apply and also all run a block on an object. They differ on just two things: do you refer to the object as it or this, and does the call return the object or the block's result?
val len = name?.let { println("Hi $it") it.length}Works, but still thinking in Java
fun city(u: User?): String { if (u != null) { val a = u.address if (a != null && a.city != null) { return a.city } } return "unknown"}fun city(u: User?) = u?.address?.city ?: "unknown"
Safe calls and Elvis collapse nested null checks into one expression, and the compiler proves nothing can be null at the end.
- JetBrains. Kotlin language documentation and release history. kotlinlang.org.
- Android Developers. Android's Kotlin-first approach.
- JetBrains. (2024). Celebrating Kotlin 2.0: Fast, smart, and multiplatform. Kotlin Blog.