On this page
Many candidates can launch a coroutine. Fewer can explain what happens when one child fails, why a catch (e: Exception) breaks cancellation, or how stateIn shares an upstream. Those are exactly the questions that distinguish experienced Android developers.
Basics
launch vs async?
launch returns a Job for fire-and-forget work. async returns a Deferred<T> you await. Use async for parallel work whose results you combine, inside coroutineScope.
Is a coroutine a thread?
No. It's a lightweight unit of work that runs on threads provided by dispatchers, and it doesn't hold a thread while suspended.
What does withContext do?
It switches the dispatcher (and context) for a block and returns its result, which is the standard way to make a suspend function main-safe.
Cancellation and exceptions
How is cancellation implemented?
Cooperatively: suspension points check for cancellation and throw CancellationException. CPU-bound loops should call ensureActive() or yield().
What's wrong with this code?
viewModelScope.launch {
try {
repository.sync()
} catch (e: Exception) { // catches CancellationException too
_state.value = Error
}
}It swallows cancellation, so a cancelled coroutine may continue and update state after the screen is gone. Catch specific exceptions, or rethrow CancellationException.
How do exceptions propagate in launch vs async?
In launch, uncaught exceptions propagate to the parent (or a CoroutineExceptionHandler at the root). In async, they're stored in the Deferred and thrown on await, and they still cancel the parent in a regular scope.
What does CoroutineExceptionHandler do?
It handles uncaught exceptions in root coroutines (launch-based) as a last resort, for example logging. It doesn't recover the failed coroutine, and it isn't invoked for async or for child coroutines.
Android specifics
Which scopes do you use on Android?
viewModelScope for screen work, lifecycleScope with repeatOnLifecycle for UI collection, an injected application scope for work that must outlive screens, and WorkManager for guaranteed background work.
Why is GlobalScope discouraged?
It isn't tied to any lifecycle, so work leaks, can't be cancelled structurally, and errors are easy to lose.
Flow
Cold vs hot flows?
Cold flows run their producer per collector (flow { }, Room queries). Hot flows exist independently and share emissions (StateFlow, SharedFlow).
StateFlow vs SharedFlow vs LiveData?
StateFlow has a current value, conflation and equality-based de-duplication, which suits UI state. SharedFlow is configurable (replay, buffer). LiveData is lifecycle-aware but Android-only and less flexible.
What does flatMapLatest do, and when would you use it?
It cancels the previous inner flow when a new value arrives, as in search-as-you-type, so outdated results never overwrite new ones.
Explain stateIn(scope, WhileSubscribed(5000), initial).
It converts a cold flow into a shared StateFlow. The upstream runs while there are subscribers, and stops five seconds after the last one leaves, which survives rotation.
What is backpressure in Flow?
Flow is sequential by default: the producer suspends until the collector processes each value. Operators like buffer, conflate and collectLatest change that behaviour.
Testing
How do you test coroutine code deterministically?
Use runTest with a test dispatcher shared with a Dispatchers.setMain rule, inject other dispatchers, and use virtual time (advanceTimeBy, advanceUntilIdle). Collect StateFlows in backgroundScope, or use Turbine. See Testing ViewModels.
Frequently asked questions
Will they ask about Channels?
Sometimes: Channel vs SharedFlow, buffered channels for one-off events, and receiveAsFlow. Know the delivery semantics: each element goes to one receiver.
Should I mention RxJava?
If you've used it, compare: coroutines integrate with Kotlin and Jetpack, and Flow covers most Rx use cases. Migration can be gradual.
Conclusion
Coroutine interviews focus on structured concurrency, cancellation, exception propagation, Android scopes, cold vs hot flows, key operators and testing. Explain each with a small snippet and the bug it prevents.
Next step: tackle bigger-picture questions in Android System Design Interview Questions.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
Kotlin fluency makes everything else in Android easier, from coroutines and Flow to Compose and clean architecture. The fastest way to build that fluency is to write real Kotlin every day and get feedback on it.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.