๐ŸŽฏ Android Interview Preparation and Career

Coroutines and Flow Interview Questions

Coroutines and Flow questions test whether you can write asynchronous Android code that is correct under cancellation, failure and lifecycle changes. Here are the questions interviewers commonly ask, with precise answers and short code you can explain.

โœ๏ธ Yunok Tech ๐Ÿ“… Updated โฑ 3 min read ๐ŸŽฏ Advanced
On this page
  1. Basics
  2. Cancellation and exceptions
  3. Android specifics
  4. Flow
  5. Testing
  6. Frequently asked questions
  7. Conclusion

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.

Failure propagation with Job versus SupervisorJob Left: with a regular Job, when child B fails, the parent is cancelled and so is sibling A. Right: with a SupervisorJob, child B's failure does not cancel the parent or sibling A; B must handle its own exception. Job / coroutineScope parent โœ— cancelled child A โœ— child B fails SupervisorJob / supervisorScope parent โœ“ continues child A โœ“ child B fails viewModelScope uses a SupervisorJob, so one failed launch doesn't kill the others.
A favourite interview topic: draw this and explain it.

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?

Interview snippetKotlin
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.

See all our apps โ†’

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.

Share: LinkedIn X / Twitter WhatsApp