Android Kotlin Interview Questions
Language fundamentals and best practices.
50 questions in this topic · 8 sample questions below
Practice Kotlin in the quiz engine
Sample questions
You declare val list = mutableListOf(1, 2, 3) and then call list.add(4). What happens?
Why: val only makes the reference read-only, not the object it points to; a MutableList can still be mutated. The misconception is that val implies immutability of the contents.
What is the key difference between a read-only List and a truly immutable list in Kotlin?
Why: The List interface only omits mutating methods; the actual instance can be a MutableList held by another reference that mutates it, so read-only is not a true immutability guarantee. Kotlin's stdlib does not provide deeply immutable collection types by default.
A Java method returns String with no nullability annotation. In Kotlin you write val s: String = javaCall(). If javaCall returns null at runtime, when does the failure surface?
Why: Platform types let you choose the nullability; assigning to a non-null String inserts an intrinsic null-check that throws right at the assignment. The trap is assuming platform types are checked at compile time.
What does the expression a ?: b evaluate to when a is not null?
Why: The Elvis operator returns the left operand when it is non-null and only evaluates the right operand otherwise, so b is short-circuited. It does not eagerly evaluate the fallback.
Given val x: String? = null, what does x?.length ?: -1 return?
Why: x?.length short-circuits to null when x is null, and the Elvis operator then supplies -1. It does not throw, because the safe call guards the receiver.
Why does a smart cast fail on an open val or a var declared in another module, even after an explicit null check?
Why: Smart casts need a stability guarantee; an open val may be overridden with a custom getter and a mutable or foreign property could change between check and use, so the compiler refuses. Local vals are always smart-castable because they cannot change.
What does the crossinline modifier on a lambda parameter of an inline function enforce?
Why: crossinline keeps the lambda inlined yet disallows non-local return-from-enclosing returns, which is needed when the lambda is invoked from a different execution context like another lambda. noinline, by contrast, opts the lambda out of inlining entirely.
Why can you write T::class inside an inline fun with a reified type parameter but not in a normal generic function?
Why: Because the inline function body is copied to each call site, a reified parameter can be replaced by the concrete type argument known there, so T::class and is T work. Regular generics are erased at runtime and have no such information.
Practice all 50 Kotlin questions
These 8 are a sample. The full Kotlin bank is scored, tracks your progress, and explains every answer.
More Android interview topics
- Android Hilt interview questions
- Android Coroutines & Flow interview questions
- Android Room interview questions
- Android Design Patterns interview questions
- Android Mobile System Design interview questions
- Android Coding Interview Patterns interview questions
- Android NDK interview questions
- Android Sensors interview questions
- Android Security interview questions
- Android Jetpack Compose interview questions
- Android Canvas & Animation interview questions
- Android CI/CD interview questions
- Android Git interview questions
- Android Unit Testing interview questions
- Android Retrofit interview questions
- Android Architecture interview questions
- Android Android Framework interview questions
- Android Kotlin Multiplatform interview questions
- Android WorkManager & Background interview questions
- Android Performance & Memory interview questions