Kotlin has been Google's preferred language for Android since 2019, and almost every Android interview now opens with Kotlin questions before it gets to Compose or architecture. This list is the set of questions I see come up again and again when preparing students for Android roles, grouped from basic to advanced, with short answers and code you can actually run.
Read the answer, then close the page and try to explain it out loud. Interviewers rarely want a textbook definition; they want to see that you have used the feature and know where it bites.
Basics
1. What is the difference between val and var?
val is a read-only reference: once assigned, it cannot point to something else. var can be reassigned. A common follow-up: does val make the object immutable? No.
val items = mutableListOf(1, 2)
items.add(3) // fine: the list is mutable
// items = mutableListOf() // error: val cannot be reassigned
2. What is the difference between val and const val?
const val is a compile-time constant. It must be a primitive or String, declared at top level or inside an object/companion object, and its value is inlined at the call site. A plain val is evaluated at runtime and can hold the result of a function call.
3. How does Kotlin handle null safety?
Types are non-null by default. String can never hold null; String? can. The compiler forces you to deal with the nullable case before you use it.
fun length(name: String?): Int = name?.length ?: 0
The tools to know: safe call ?., the Elvis operator ?:, smart casts after an if (x != null) check, let for scoped null handling, and the not-null assertion !!, which throws a NullPointerException if the value is null. In an interview, say that you treat !! as a code smell and prefer a safe call, an Elvis default or an early return.
4. What is the difference between == and ===?
== is structural equality: it calls equals() and is null-safe. === is referential equality: both sides are the same instance.
5. What are data classes and what does the compiler generate?
A data class gets equals(), hashCode(), toString(), copy() and componentN() functions generated from the properties in its primary constructor. Properties declared in the class body are not included.
data class User(val id: Int, val name: String)
val a = User(1, "Asha")
val b = a.copy(name = "Bala")
val (id, name) = b // destructuring via component1(), component2()
Follow-up: copy() is a shallow copy. If a property is a mutable list, both copies share it, which is one reason to keep data classes immutable.
6. What is a string template?
"Hello, $name" or "Total: ${price * qty}". Expressions go inside ${}.
7. What is when and how is it different from Java's switch?
when is an expression, so it returns a value. Branches can match constants, ranges (in 1..9), types (is String) or arbitrary conditions. Used with an enum or sealed type, it can be exhaustive with no else.
8. What are extension functions?
They let you add a function to a type you do not own, without inheritance.
fun String.isValidEmail(): Boolean =
contains("@") && substringAfter("@").contains(".")
They are resolved statically: the declared type decides which extension is called, not the runtime type. They also cannot access private members of the class.
Classes and objects
9. Why are Kotlin classes final by default?
Classes and members are closed unless marked open. This follows the "design for inheritance or prohibit it" principle and avoids fragile base classes. Android teams lean on composition and interfaces anyway.
10. What is the difference between a sealed class and an enum?
An enum has a fixed set of instances, each with the same shape. A sealed class or sealed interface has a fixed set of subtypes, and each subtype can carry different data.
sealed interface UiState {
data object Loading : UiState
data class Success(val items: List<String>) : UiState
data class Error(val message: String) : UiState
}
fun render(state: UiState): String = when (state) {
UiState.Loading -> "Loading"
is UiState.Success -> "${state.items.size} items"
is UiState.Error -> state.message
}
data object (stable since Kotlin 1.9) gives a singleton a readable toString(), which is handy for states like Loading.
11. What is object and what is a companion object?
object declares a singleton, created lazily and thread-safely on first access. A companion object is a singleton tied to a class, used for factory functions and constants. Kotlin has no static keyword; @JvmStatic exposes companion members as real statics for Java callers.
12. What is the difference between lateinit and by lazy?
lateinit var: a mutable, non-null property you promise to initialise before use. Not allowed for primitive types. Accessing it early throwsUninitializedPropertyAccessException. You can check::prop.isInitialized.val x by lazy { ... }: a read-only property computed on first access and cached. By default it is synchronized, so it is thread-safe.
13. What are value classes?
@JvmInline value class UserId(val raw: String) wraps a single value for type safety without allocating a wrapper object in most cases. Use them so you cannot accidentally pass an OrderId where a UserId is expected.
14. How does delegation with by work?
Class delegation forwards an interface's methods to another object:
class LoggingList<T>(private val inner: MutableList<T>) : MutableList<T> by inner {
override fun add(element: T): Boolean {
println("add $element")
return inner.add(element)
}
}
Property delegation (by lazy, by Delegates.observable, by viewModels() in Android) hands the getter and setter to a delegate object.
Functions and functional style
15. What are higher-order functions and lambdas?
A higher-order function takes or returns a function. list.filter { it > 0 } passes a lambda. Function types look like (Int) -> Boolean.
16. Explain let, run, with, apply and also.
This is one of the most common Kotlin interview questions. Two things differ: how the object is referenced (it or this) and what is returned (the lambda result or the object itself).
let: object isit, returns the lambda result. Typical use:value?.let { use(it) }.run: object isthis, returns the lambda result. Compute something from an object.with(obj) { }: same asrun, but not an extension. Group calls on one object.apply: object isthis, returns the object. Configure an object after creating it.also: object isit, returns the object. Side effects such as logging.
val request = Request.Builder().apply {
url("https://example.com")
header("Accept", "application/json")
}.build()
Good answer to add: do not nest scope functions deeply; readability drops fast.
17. What are inline functions and why do they exist?
Each lambda normally becomes an object. Marking a higher-order function inline copies its body and the lambda's body into the call site, which removes that allocation. It also allows non-local return from inside the lambda. noinline excludes a specific lambda parameter; crossinline forbids non-local returns when the lambda is called from another context.
18. What are reified type parameters?
Generics are erased at runtime on the JVM, so T::class is not normally available. In an inline function you can mark the type parameter reified and use it:
inline fun <reified T> Any.isOfType(): Boolean = this is T
19. What are default and named arguments?
Parameters can have defaults, and callers can name arguments, which removes most of the need for builder classes and overloads. @JvmOverloads generates overloads for Java callers.
Collections and generics
20. What is the difference between List and MutableList?
List is a read-only view: it has no add or remove. It is not guaranteed immutable, because the same object might be a MutableList underneath. Expose List from a class and keep MutableList private.
21. What is the difference between map, flatMap and associateBy?
map transforms each item one-to-one. flatMap maps each item to a collection and flattens the result. associateBy { it.id } builds a Map keyed by a selector.
22. What are sequences and when do they help?
Collection operations are eager: each step builds a new list. A Sequence is lazy and processes items one by one through the whole chain, stopping early with first() or take(). Use sequences for long chains on large data; for small lists, plain collections are usually faster.
23. What do in and out mean in generics?
Declaration-site variance. out T means the type only produces T (covariant), so List<String> is a List<Any>. in T means it only consumes T (contravariant), as in Comparable<in T>. Use-site variance (Array<out Number>) and star projection (List<*>) are the follow-ups.
Coroutines (the short version)
24. What is a suspend function?
A function that can pause without blocking its thread and resume later. It can only be called from a coroutine or another suspend function. The compiler turns it into a state machine with a continuation parameter.
25. What is structured concurrency?
Coroutines run inside a CoroutineScope. When the scope is cancelled, all its children are cancelled; a parent waits for its children to finish. On Android, viewModelScope and lifecycleScope tie this to a lifecycle, so work stops when the screen goes away.
For a full set of coroutine and Flow questions, see Kotlin coroutines and Flow interview questions.
Kotlin 2.x and current practice
26. What changed in Kotlin 2.0?
The K2 compiler became the default. It compiles faster, has a single front end for JVM, Native, JS and Wasm, and handles smart casts in more cases (for example, after || checks and for local variables captured in some lambdas). For Android developers, the Jetpack Compose compiler now ships with Kotlin and is applied with the org.jetbrains.kotlin.plugin.compose Gradle plugin, so you no longer match a separate Compose compiler version to your Kotlin version.
27. What is Kotlin Multiplatform?
KMP lets you share Kotlin code (business logic, networking, storage) across Android, iOS, desktop and web, with expect/actual declarations for platform-specific parts. Compose Multiplatform extends this to shared UI. Interviewers mostly want to know you understand the idea, not that you have shipped iOS.
28. What is the difference between Any, Unit and Nothing?
Any is the root of all non-null types. Unit is the type of a function that returns no meaningful value; it has exactly one value. Nothing has no values and marks code that never returns, such as throw or TODO(). Because Nothing is a subtype of every type, val x: String = y ?: throw IllegalStateException() compiles.
29. How do you write idiomatic Kotlin for a Java-heavy team?
Talk about immutability first (val, read-only collections), sealed types for state, extension functions instead of utility classes, require/check for preconditions, and avoiding !!. Show that you can mix Kotlin and Java in one module with annotations like @JvmStatic, @JvmOverloads and @Throws.
30. Write a function that returns the first non-repeating character in a string.
A typical whiteboard question:
fun firstUnique(s: String): Char? {
val counts = s.groupingBy { it }.eachCount()
return s.firstOrNull { counts[it] == 1 }
}
Explain the complexity: two passes, O(n) time, O(k) extra space for k distinct characters.
How to prepare
Interviews for Android roles test Kotlin through code, not trivia. Build one small app end to end, write the ViewModel and repository yourself, and be ready to explain every line. Then move on to the Jetpack Compose interview questions and Android architecture interview questions, because a Kotlin round usually flows straight into them.
Learn Kotlin with a trainer who ships apps
I have trained developers for 12+ years, founded AndroidManifester (now TechManifester) in Chennai in 2016, and I still ship my own Android apps, so the Kotlin we cover is the Kotlin used in real projects today. See the Kotlin training in Chennai course, the wider Android training in Chennai program, or browse all training programs.
K P Ranjith Kumar is a former Google Certified Associate Android Developer and the founder of TechManifester. He has taught Android, Kotlin and Flutter for over 12 years.