On this page
For experienced roles, interviewers probe whether you understand Kotlin's design: what the compiler does, why rules exist, and when features are the wrong tool. Answer with the principle, a short example and a trade-off.
Type system
Why is MutableList<Dog> not a MutableList<Animal>?
Because a mutable list both produces and consumes elements, so it's invariant. If it were covariant, you could add a Cat through the Animal reference. List<out E> is read-only and covariant, so List<Dog> is a List<Animal>.
What is Nothing and where is it useful?
The bottom type, with no values. It's the subtype of everything. Functions that never return (throw, TODO()) return Nothing, and it lets Result.Failure : Result<Nothing> fit any Result<out T>.
What are value classes?
@JvmInline value class UserId(val raw: String)
@JvmInline value class OrderId(val raw: String)
fun loadOrder(user: UserId, order: OrderId) { /* can't accidentally swap them */ }A value class wraps a single value for type safety, and is usually represented as the underlying type at runtime. It's boxed when used as a generic or nullable type.
Functions and compilation
What does inline change, and what are noinline and crossinline?
Inlining copies the body and lambdas into call sites, which avoids lambda objects and enables non-local returns and reified. noinline keeps a lambda as an object (to store or pass it). crossinline forbids non-local return when the lambda runs in another context. The cost is larger bytecode.
How are extension functions compiled?
As static methods taking the receiver as the first parameter. They're resolved statically and can't access private members.
What does the compiler generate for a suspend function?
A state machine with a hidden Continuation parameter. Local variables are stored in the continuation across suspension points, and the function returns COROUTINE_SUSPENDED when it suspends.
Classes and delegation
Sealed class vs sealed interface vs enum?
Enums have fixed instances with the same shape. Sealed hierarchies allow subtypes with different data. Sealed interfaces allow multiple inheritance and lighter declarations. All give exhaustive when.
How does by delegation work for classes and properties?
Class delegation generates forwarding methods to a delegate instance (decorator pattern). Property delegation routes get and set to getValue/setValue (for example lazy, viewModels(), Compose state). See Delegation.
What's tricky about data class equals?
Only primary-constructor properties take part. Mutable properties in data classes used as map keys or in sets cause bugs when they change. Arrays compare by reference unless you override equality.
Coroutines and Flow (advanced)
coroutineScope vs supervisorScope?
In coroutineScope, a failing child cancels siblings and the parent. In supervisorScope, child failures are isolated, so each child must handle its own errors.
Why must you rethrow CancellationException?
Cancellation is implemented with this exception. Swallowing it keeps cancelled work running and breaks structured concurrency.
flatMapLatest vs flatMapConcat vs flatMapMerge?
Latest cancels the previous inner flow (search-as-you-type). Concat processes sequentially. Merge runs concurrently, with a concurrency limit.
How does stateIn(WhileSubscribed(5000)) behave?
It starts the upstream when the first collector appears and stops it five seconds after the last disappears, which survives configuration changes without leaking work.
DSLs and idioms
How do type-safe builders work?
They use lambdas with receivers (T.() -> Unit), often with @DslMarker to prevent accidental access to outer receivers. Compose's layout scopes and the Gradle Kotlin DSL use this.
@DslMarker annotation class MenuDsl
@MenuDsl class Menu { val items = mutableListOf<String>(); fun item(title: String) { items += title } }
fun menu(build: Menu.() -> Unit): Menu = Menu().apply(build)
val m = menu { item("Home"); item("Settings") }Performance awareness
- Sequences vs lists: lazy, which helps large chains and short-circuiting.
- Boxing with generics and nullable primitives.
- Lambdas capturing variables allocate objects unless inlined.
lazysynchronisation modes.
Frequently asked questions
Will I be asked about Kotlin Multiplatform?
Increasingly, yes: expect/actual, what can be shared, and trade-offs. See KMP vs Native.
How deep should I know compiler internals?
Enough to explain behaviour (suspend state machines, inline, extensions), not to recite bytecode.
Conclusion
Senior Kotlin interviews test understanding of the type system, compilation, delegation and coroutine semantics. Answer with principle, example and trade-off, and connect each answer to real Android code you've written.
Next step: prepare UI questions with Jetpack Compose Interview Questions.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
Interviews reward developers who can explain why, not just how. Build the Kotlin, Compose and architecture depth that lets you discuss real trade-offs with confidence.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.