Kotlin is the preferred language for Android development and is widely used for backend services, multiplatform apps and scripting. These Kotlin interview questions cover the topics interviewers ask most, from language basics to coroutines, with short code examples you can practise.
Key takeaways
- Master null safety, val versus var, data classes and extension functions.
- Understand scope functions, sealed classes and companion objects.
- Be ready to explain coroutines, suspend functions and Flow.
- Know where Kotlin is used today, including Android, server-side and Kotlin Multiplatform.
Kotlin basics
1. What is Kotlin?
Kotlin is a modern, statically typed programming language developed by JetBrains. It runs on the JVM, compiles to JavaScript and native code, and is fully interoperable with Java. Google made it the preferred language for Android development.
2. What is the difference between val and var?
val declares a read-only reference that cannot be reassigned after initialisation, similar to final in Java. var declares a mutable variable that can be reassigned. Note that a val holding a mutable object can still have its contents changed.
val name = "Asha" // cannot be reassigned
var count = 0 // can be reassigned
count += 1 3. How does Kotlin handle null safety?
Types are non-nullable by default. To allow null, you add ? to the type. Kotlin then forces you to handle nulls safely with the safe call operator ?., the Elvis operator ?: or explicit checks, which removes most NullPointerExceptions at compile time.
val email: String? = user.email
val length = email?.length ?: 0 4. What does the !! operator do?
The not-null assertion operator converts a nullable type to non-null and throws a NullPointerException if the value is null. It should be used rarely, only when you are certain the value cannot be null.
5. What are data classes?
A data class is designed to hold data. The compiler automatically generates equals(), hashCode(), toString(), copy() and component functions for destructuring.
data class Course(val name: String, val level: String)
val c2 = Course("Kotlin", "Beginner").copy(level = "Advanced") 6. What is string interpolation?
Kotlin lets you insert values directly into strings with $name or expressions with ${expression}, which is cleaner than concatenation.
7. What is the difference between == and ===?
== checks structural equality by calling equals(). === checks referential equality, meaning both references point to the same object.
Functions and classes
8. What are extension functions?
Extension functions add new functions to existing classes without inheriting from them or modifying their source code.
fun String.initials(): String =
split(" ").mapNotNull { it.firstOrNull()?.uppercase() }.joinToString("") 9. What are default and named arguments?
Functions can declare default parameter values, and callers can pass arguments by name in any order. This reduces the need for overloaded functions and makes calls easier to read.
10. What are higher-order functions and lambdas?
A higher-order function takes functions as parameters or returns a function. Lambdas are concise anonymous functions, used heavily with collections, for example list.filter { it > 10 }.
11. What are scope functions?
let, run, with, apply and also execute a block in the context of an object. They differ in how the object is referenced (this or it) and what they return. For example, apply is common for configuring an object, and let for working with nullable values.
12. What is a companion object?
A companion object is declared inside a class and holds members that belong to the class rather than to instances, similar to static members in Java. It is often used for factory functions and constants.
13. What is an object declaration?
The object keyword creates a singleton: a class with exactly one instance, created lazily when first accessed.
14. What are sealed classes and interfaces?
A sealed class or interface restricts which subclasses can exist, all known at compile time. This makes when expressions exhaustive, which is ideal for modelling states such as Loading, Success and Error.
sealed interface UiState {
object Loading : UiState
data class Success(val items: List<String>) : UiState
data class Error(val message: String) : UiState
} 15. Are Kotlin classes final by default?
Yes. Classes and members are final by default. You must mark them open to allow inheritance or overriding, which encourages safer designs.
16. What is the difference between lateinit and lazy?
lateinit is used with var properties of non-null types that will be initialised later, such as dependencies injected after construction. lazy is used with val and computes the value on first access, then caches it.
Coroutines and concurrency
17. What are coroutines?
Coroutines are Kotlin’s approach to asynchronous programming. They let you write non-blocking code that reads like sequential code, and they are much lighter than threads, so thousands can run at once.
18. What is a suspend function?
A suspend function can pause without blocking a thread and resume later. It can only be called from another suspend function or a coroutine.
suspend fun loadCourses(): List<Course> = withContext(Dispatchers.IO) {
api.fetchCourses()
} 19. What are launch and async?
launch starts a coroutine that does not return a result and returns a Job. async starts a coroutine that returns a Deferred result, which you retrieve with await().
20. What are dispatchers?
Dispatchers decide which threads a coroutine runs on: Dispatchers.Main for UI work on Android, Dispatchers.IO for network and disk operations, and Dispatchers.Default for CPU-intensive work.
21. What is structured concurrency?
Coroutines run within a scope, and a parent scope waits for its children and cancels them if it is cancelled. This prevents leaks and makes error handling predictable. On Android, viewModelScope and lifecycleScope are common scopes.
22. What is Flow?
Flow is a cold asynchronous stream that emits multiple values over time. StateFlow and SharedFlow are hot variants commonly used to expose UI state and events.
Kotlin in practice
23. Why is Kotlin preferred for Android development?
It is concise, null-safe, fully interoperable with Java and supported first by Google, including modern tools such as Jetpack Compose, which is built with Kotlin.
24. What is Kotlin Multiplatform?
Kotlin Multiplatform lets teams share business logic across Android, iOS, desktop, web and backend while keeping native user interfaces where needed.
25. How does Kotlin interoperate with Java?
Kotlin code can call Java and Java can call Kotlin. Annotations such as @JvmStatic, @JvmOverloads and @JvmField help make Kotlin APIs feel natural from Java.
Frequently asked questions
Is Kotlin hard to learn for Java developers?
No. Java developers usually become productive in Kotlin quickly because the concepts are familiar and the syntax is more concise.
What should I practise before a Kotlin interview?
Write small programs using data classes, collections, null safety, sealed classes and coroutines, and be ready to explain your choices.
Next steps
Strengthen your programming foundations with our live Python training or React JS training, browse more interview questions, and build an interview-ready CV with our free resume builder.