Home › Blog › Kotlin interview questions with answer outlines

Kotlin interview questions with answer outlines

Kotlin interviews — mostly for Android and increasingly for backend roles — test the language features that make Kotlin safer and more concise than Java: null safety, immutability, data and sealed classes, extension and higher-order functions, scope functions, coroutines and flows, and interoperability with Java. Expect “what does this print?” snippets and questions on structured concurrency, which is where many candidates are weakest.

Fifteen common Kotlin interview questions

  1. How does Kotlin's null safety work?
  2. What do ?., ?: and !! do?
  3. val versus var? const versus val?
  4. What does a data class generate?
  5. What are sealed classes, and why pair them with when?
  6. What are extension functions?
  7. Explain let, run, with, apply and also.
  8. What is a higher-order function? An inline function?
  9. lateinit versus lazy?
  10. What are coroutines, and how do they differ from threads?
  11. launch versus async? What is structured concurrency?
  12. What are dispatchers?
  13. Flow versus StateFlow versus SharedFlow?
  14. What is the difference between object and companion object?
  15. How does Kotlin interoperate with Java?

Null safety and immutability

Classes and functions

FeatureAnswer
Data classGenerates equals, hashCode, toString, copy and componentN functions
Sealed class / interfaceA closed set of subtypes, so when expressions can be exhaustive without else
Extension functionAdds a function to an existing type without inheritance, resolved statically
objectA singleton declaration
companion objectClass-level members, similar to Java statics
inline functionInlines the function and lambda at call sites, avoiding allocation; enables reified generics

Scope functions

let and also pass the object as it; run, with and apply use this. let, run and with return the lambda's result; apply and also return the object itself. Typical uses: let for null-checked transformations, apply for configuring an object, also for side effects such as logging, run for computing a result in an object's scope. Interviewers mostly want to see you choose one for readability, not memorise a matrix.

Coroutines and flows

Coroutines are lightweight, suspendable computations: suspending frees the thread instead of blocking it, so thousands can run on a few threads. launch starts a coroutine that returns a Job; async returns a Deferred whose result you await. Structured concurrency means coroutines run inside a scope — such as viewModelScope on Android — so cancelling the scope cancels its children and failures propagate predictably. Dispatchers choose threads: Main for UI, IO for blocking I/O, Default for CPU work. A Flow is a cold asynchronous stream; StateFlow holds and emits a current state (ideal for UI state); SharedFlow broadcasts events to multiple collectors.

Java interoperability

Kotlin compiles to JVM bytecode and calls Java directly. Java types without nullability annotations appear as platform types, so null safety isn't guaranteed at those boundaries. Annotations such as @JvmStatic, @JvmOverloads and @JvmField make Kotlin APIs friendlier to Java callers. See Java interview questions and Android interview questions.

Kotlin on the backend

For backend roles, expect questions on using coroutines with frameworks such as Ktor or Spring, how suspending functions interact with blocking JDBC drivers (wrap them in the IO dispatcher or use non-blocking drivers), serialisation, and testing coroutines with test dispatchers. The language questions are the same; the context shifts from UI threads to request handling and throughput.

Practising

Reading answers is not the same as saying them. Pick ten of the questions above and answer them aloud against a timer; a free AI interview assistant like CoPilot Interview can ask Kotlin questions in a mock interview and flag answers that ran long or lacked an example. Write a small ViewModel that loads data with coroutines into a StateFlow, and explain cancellation and error handling aloud.

Disclosure: CoPilot Interview is our product, so weigh what we say about it accordingly. Everything else on this page applies whichever tool you use, or none.

Frequently asked questions

What are common Kotlin interview questions?

Null safety operators, val versus var, data and sealed classes, extension functions, scope functions, higher-order and inline functions, lateinit versus lazy, coroutines, structured concurrency, dispatchers, flows and Java interop.

What is the difference between launch and async?

launch starts a coroutine for work without a result and returns a Job; async starts one that produces a result, returned as a Deferred you await.

StateFlow or SharedFlow?

StateFlow always holds a current value and suits UI state. SharedFlow broadcasts events without needing a current value and suits one-off events or multiple subscribers.

Why avoid the !! operator?

It throws a NullPointerException if the value is null, defeating Kotlin's null safety. Safe calls, the Elvis operator or explicit checks are usually better.

Practise on real interview questions

Run 145 real interview questions across 10 tracks, answer out loud and see a structured answer to compare with yours. Free, no signup.

Try a practice question