Kotlin interview questions for senior Android engineers
By Mike Salari. Staff mobile engineer · 500+ technical interviews from the hiring side.
This page is for Android engineers whose loop includes a Kotlin language round. You get ten questions about what the compiler knows and what it generates, with the scoring, the follow-up chain and the weak answer for each. Coroutines and threading live on a separate page, so this one stays on the language.
Who this is for
- Senior Android engineers who write Kotlin daily but rarely explain it out loud.
- Engineers in mixed Java and Kotlin codebases who own the boundary between the two.
- Leads who interview others and want a shared bar for a senior Kotlin answer.
If you need syntax, read the Kotlin docs. This page is about the second and third "why".
A second set covering null safety, coroutines, Flow and sealed types, each with its follow-up, is in the Kotlin guide on Mobile Interview Room.
The questions
In a senior round the follow-up carries more weight than the first answer. A Kotlin keyword on its own earns little. What an interviewer can defend in the debrief is the contract you protected, the mutation you prevented, or the cost you made visible.
1. "Model loading, success and error for a repository result."
What is scored: whether wrong states fail at compile time.
A strong answer covers:
- Context: three fields like
isLoading,data,errorgive eight combinations and only three make sense. Every screen then decides what the other five mean, and screens disagree. - Decision: a sealed interface where each case carries only its own data. A
whenover it needs noelsewhen all cases are covered. (Kotlin docs: sealed classes) - The variance detail:
out TplusNothingfor valueless cases letsErrorfit anyUiState<T>. - Alternative: a sealed class, worth it only when the parent owns shared state. An enum class can implement a sealed interface but cannot extend a sealed class.
- Failure mode: an
elsebranch. The next added case falls into it silently instead of breaking the build.
sealed interface UiState<out T> {
data object Loading : UiState<Nothing>
data class Success<T>(val data: T) : UiState<T>
data class Error(val cause: Throwable) : UiState<Nothing>
}Follow-ups:
- Next quarter you add an
Emptycase. What happens across the codebase? - The type now lives in a public library. Is adding a case still a feature, or a breaking change?
Weak answer: a data class with three nullable fields "because it is simple". It moves the bug from the compiler to QA.
2. "Two IDs are both String, and someone swapped them at a call site. How do you stop that?"
What is scored: type safety, and knowing what it costs at runtime.
A strong answer covers:
- A
typealias UserId = Stringis a name only. It still accepts any string. - A value class gives a distinct compile-time type around one property, and can validate in an
initblock. (Kotlin docs: inline value classes) - The cost edges: the docs say a value class is boxed whenever it is used as another type, such as a generic
T, an interface it implements, or its nullable form. - Limit: exactly one stored property, so money with a currency needs a data class or two values.
@JvmInline value class UserId(val raw: String)
@JvmInline value class OrderId(val raw: String)
fun cancelOrder(user: UserId, order: OrderId) { /* ... */ }
// cancelOrder(orderId, userId) no longer compilesFollow-ups:
- The ID goes into a
List<UserId>in a hot path. What changes? - Prices are
Doubletoday. What do you replace them with, and why one property is not enough?
Weak answer: "A type alias gives the same safety and both are free." Neither half is true.
3. "A legacy codebase has hundreds of !!. How do you fix it at scale?"
What is scored: fixing nullability where it enters the code.
A strong answer covers:
- Where they come from: unannotated Java returns platform types (
T!). The compiler does not check calls on them, and assigning one to a non-null type adds a runtime assertion. (Kotlin docs: Java interop) - Fix the border first: annotate the Java you own. JSpecify annotations turn into real nullable or non-null Kotlin types, and mismatches are errors by default.
- Classify what is left: impossible nulls become
checkNotNull(x) { "context" }with a useful message; possible nulls get a safe call and a domain default. - Map nullable DTOs to a non-null domain model once, in the repository, so no other file repeats the chain.
- Ratchet: a CI count of
!!that can only go down.
Follow-ups:
- You do not own the Java SDK. What do you do instead of annotating it?
- A missing ID means the item cannot open. Do you drop the item, show a limited row, or fail the response?
Weak answer: "Replace every !! with ?.." It hides the crash and spreads silent empty states.
4. "Explain inline, noinline and crossinline. When would you avoid inline?"
What is scored: knowing what the compiler copies, and where that hurts.
A strong answer covers:
inlinecopies the function and its lambda into the call site, so no function object is allocated. It also enablesreifiedtype parameters and non-localreturn. (Kotlin docs: inline functions)noinlinekeeps one lambda as a real object you can store or pass on.crossinlineis needed when the lambda runs in another context, such as inside an object, and forbids non-local returns there.- When to avoid it: large bodies copied into many call sites, and public library functions. A public inline function is compiled into the caller's module, so a library fix does not reach callers until they recompile.
import android.os.Trace
inline fun <T> traced(name: String, block: () -> T): T {
Trace.beginSection(name)
try { return block() } finally { Trace.endSection() }
}Follow-ups:
- Why can a public inline function not call a
privatehelper, and what does@PublishedApichange? - The lambda is stored in a field for later. Which modifier, and what does it cost?
Weak answer: "Inline makes everything faster." It ignores code size and binary compatibility.
5. "How does by lazy work, and when is it the wrong tool?"
What is scored: reading a delegate as generated code.
A strong answer covers:
- The property read goes through the delegate. The first read runs the initializer and later reads get the cached value.
- Thread safety: by default the value is computed in one thread and all threads see the same value.
PUBLICATIONallows several threads to run the initializer.NONEdrops the guarantees and belongs only to single-thread use. (Kotlin docs: delegated properties) - Useful Android delegates: a property backed by
SavedStateHandle, preferences, view binding. - The design rule: property syntax promises a cheap read. A delegate that hides disk I/O behind a property lies about cost.
Follow-ups:
- The lazy value is first read on the main thread and its initializer parses a large file. What do you change?
- Where is
LazyThreadSafetyMode.NONEsafe, and how would you prove it?
Weak answer: "Lazy is just a nullable var with a check." It misses synchronisation and the cost of the first read.
6. "A custom View written in Kotlin crashes when inflated from XML. What happened?"
What is scored: knowing the Java face of your Kotlin.
A strong answer covers:
- XML inflation calls the two-argument constructor. Default parameters do not create Java overloads unless you add
@JvmOverloads, which generates one overload per defaulted parameter, removing from the right. (Kotlin docs: calling Kotlin from Java) @JvmStaticmakes companion functions real statics for Java callers.- Top-level and extension functions compile into a class named after the file, such as
AppKt. Moving them between files changes that class for Java callers, so pin the name with@file:JvmName. @Throwsdeclares checked exceptions so Java code can catch them.
Follow-ups:
- Which exact overloads did
@JvmOverloadsgenerate here? - You publish this as a library. What else must stay stable for Java consumers?
Weak answer: "Add every @Jvm annotation to every public API." Shape the boundary a real caller needs and check the signature it produces.
7. "A saved order in history changed after the user edited the cart. How?"
What is scored: telling a read-only reference from an immutable snapshot.
A strong answer covers:
valstops reassignment of the property. It does not freeze the object it points to.- A data class
copy()is shallow, so aListfield still points at the same list. (Kotlin docs: data classes) - The fix sits at the boundary where history is created: take a snapshot such as
items.toList(), and test that later edits cannot reach it. - Equality detail: only primary constructor properties take part in
equals(). A field in the class body can change what users see without changing equality.
data class Cart(val productIds: List<String>)
val live = mutableListOf("tea")
val history = Cart(live.toList()) // snapshot
val shared = Cart(live) // alias
live.add("coffee")
check(history.productIds == listOf("tea"))
check(shared.productIds == listOf("tea", "coffee"))Follow-ups:
- The list has thousands of items. Does history need all of it, or only IDs and amounts?
- You use the whole object as a map key. What breaks if a field changes while it is in the map?
Weak answer: "It is a val, so it cannot change." That is the bug, said with confidence.
8. "Two extension functions, one on a base type and one on a subtype. Which runs?"
What is scored: static dispatch, and the delegation hole next to it.
A strong answer covers:
- Extensions are resolved by the declared type at compile time. Called through a base-type reference, the base extension runs. (Kotlin docs: extensions)
- A member with the same signature always wins over an extension.
- The related trap: with
class Wrapper(d: Sender) : Sender by d, members you override are not called from inside the delegate. The delegate only sees its own implementations. (Kotlin docs: delegation) - So a "pause" wrapper that overrides
send()still letssendBatch()reach the originalsend().
Follow-ups:
- The interface gains an
export()method next release. Does your wrapper cover it? - When do you choose a member over an extension?
Weak answer: "Extensions add methods to the class." They do not change the class, and that sentence is where the bug starts.
9. "Why can a List<SafetyInspection> be a List<Inspection>, but a MutableList cannot?"
What is scored: variance explained as permission to read or write.
A strong answer covers:
List<out E>only produces values, so a list of subtypes can be read as a list of the parent type.MutableListboth reads and writes. If the assignment were allowed, you could add a plainInspectioninto storage that expects only safety inspections.inmarks a consumer, like a comparator or sink. Star projectionFoo<*>lets you read values asAny?without claiming their type.reifiedchecks the outer type at the call site. It does not validate the contents of a nested generic container.
Follow-ups:
- An imported batch arrives as
List<*>. What do you validate, and where? - When does a generic type parameter add nothing and should be removed?
Weak answer: "Producer extends, consumer super" with no Kotlin example. It shows you read about variance and never needed it.
10. "When do you use a Sequence instead of a List chain?"
What is scored: cost reasoning tied to a real workload.
A strong answer covers:
- A
Listchain runs each step over the whole collection and builds an intermediate list per step. - A
Sequenceruns all steps per element, lazily, and can stop early with operations liketake. (Kotlin docs: sequences) - The docs say the laziness adds overhead that can matter for small collections or simple steps. Stateful steps need to see many or all elements.
- If the source is pushed over time, the async relative is
Flow.
Follow-ups:
- The list has 20 items and two steps. Which do you pick, and how would you check?
- Where does the real cost hide in a hot path: the chain, boxing, or captured lambdas stored somewhere?
Weak answer: "Sequences are always faster because they are lazy." Without a workload, it is a guess.
What changed in 2024 to 2026
- Kotlin 2.0.0, released 21 May 2024, made the K2 compiler stable and the default on all targets. Smart casts now work through a local
val isCat = animal is Catand through||type checks. (What's new in Kotlin 2.0.0) - Kotlin ships a language release every six months. 2.1.0 (27 November 2024), 2.2.0 (23 June 2025), 2.3.0 (16 December 2025) and 2.4.0 (3 June 2026) are out, and 2.5.0 is planned for December 2026. Know your project's version before you claim a feature. (Kotlin releases)
- JSpecify annotations are read as real nullable or non-null types, and the compiler reports mismatches as errors by default. That changes the
!!story at Java boundaries. (Calling Java from Kotlin)
How the rounds run
Formats vary by company and level. Some teams ask Kotlin questions as a discussion, some inside a live coding exercise, and some fold them into an architecture round. No official careers page from a major company that I found publishes a Kotlin-specific round, so none is described here.
Ask the recruiter what each round scores, whether you code in an IDE or a shared editor, and whether Kotlin questions come with code or without. For the coroutine side, read the Android threading and performance guide. For where these types sit in an app, read the Android architecture guide.
Sources
- Kotlin docs, "What's new in Kotlin 2.0.0", released 21 May 2024, https://kotlinlang.org/docs/whatsnew20.html (accessed 21 October 2026)
- Kotlin docs, "Kotlin releases", https://kotlinlang.org/docs/releases.html (accessed 21 October 2026)
- Kotlin docs, "Calling Java from Kotlin", https://kotlinlang.org/docs/java-interop.html (accessed 21 October 2026)
- Kotlin docs, "Calling Kotlin from Java", https://kotlinlang.org/docs/java-to-kotlin-interop.html (accessed 21 October 2026)
- Kotlin docs, "Sealed classes and interfaces", https://kotlinlang.org/docs/sealed-classes.html (accessed 21 October 2026)
- Kotlin docs, "Inline value classes", https://kotlinlang.org/docs/inline-classes.html (accessed 21 October 2026)
- Kotlin docs, "Inline functions", https://kotlinlang.org/docs/inline-functions.html (accessed 21 October 2026)
- Kotlin docs, "Delegated properties", https://kotlinlang.org/docs/delegated-properties.html (accessed 21 October 2026)
- Kotlin docs, "Delegation", https://kotlinlang.org/docs/delegation.html (accessed 21 October 2026)
- Kotlin docs, "Data classes", https://kotlinlang.org/docs/data-classes.html (accessed 21 October 2026)
- Kotlin docs, "Extensions", https://kotlinlang.org/docs/extensions.html (accessed 21 October 2026)
- Kotlin docs, "Sequences", https://kotlinlang.org/docs/sequences.html (accessed 21 October 2026)
These ten questions are a sample. The Senior Signal covers the Kotlin chapter in full, from value class boxing to the Java face of a library, with the follow-ups interviewers use. Interview Runtime Android turns the same ideas into practice: you answer, the constraint changes, and you answer again.