Android Coroutines & Flow Interview Questions
Concurrency, structured scopes, and reactive streams.
50 questions in this topic · 8 sample questions below
Practice Coroutines & Flow in the quiz engine
Sample questions
Inside a coroutineScope block, one of two child coroutines launched with launch throws an exception. What happens to the sibling coroutine and the coroutineScope call?
Why: coroutineScope uses a regular Job, so a child failure cancels all siblings and the exception is rethrown by coroutineScope. It is not swallowed, and a handler is irrelevant because coroutineScope propagates by throwing, not by invoking an exception handler.
You wrap a launch call in a try/catch block. A coroutine started by that launch throws inside its body. Does the surrounding try/catch catch it?
Why: launch returns a Job immediately and runs the body asynchronously, so exceptions propagate up the coroutine hierarchy rather than to the launching code's try/catch. Wrapping launch in try/catch never catches the child's exception, even for pre-suspension throws, because the body is scheduled, not invoked inline in the general case.
A CoroutineExceptionHandler is installed in the context of a child coroutine created with launch. An uncaught exception occurs in that child. Is the handler invoked?
Why: CoroutineExceptionHandler is only honored when installed on the scope or the root coroutine that becomes responsible for the exception; a handler on an inner child is ignored because the exception propagates upward first. It is not tied to async or supervisorScope specifically.
What is the key difference between withContext(Dispatchers.IO) and async(Dispatchers.IO) for a single unit of work whose result you need immediately?
Why: withContext switches context, runs the block, suspends until it finishes, and returns the value directly, so it is sequential. async is for concurrency: it returns a Deferred you await later, which is wasteful when you need the result immediately and would only add overhead.
A tight CPU-bound while(true) loop runs inside a coroutine. You cancel the coroutine's Job. What happens?
Why: Cancellation is cooperative: a coroutine only becomes cancelled when it suspends at a cancellable point or explicitly checks isActive/ensureActive. A pure CPU loop with no suspension or checks ignores cancellation entirely, so it does not stop automatically.
Which statement about a StateFlow's initial value is correct?
Why: MutableStateFlow(initialValue) mandates an initial value, so a StateFlow always has a current value available synchronously. It is never empty and does not wait for a collector, unlike a plain cold Flow.
You set the same data class value into a MutableStateFlow twice in a row where the value equals the current value. How many emissions do collectors observe?
Why: StateFlow deduplicates using equals(): setting a value equal to the current one produces no new emission. It uses structural equality, not referential identity, so equal data class instances are treated as no change.
In a supervisorScope, a child launched with launch fails with an exception. What is the effect on its sibling coroutines?
Why: supervisorScope uses a SupervisorJob so a child's failure is isolated and does not cancel siblings or the scope. This is the opposite of coroutineScope, where any child failure cancels all others.
Practice all 50 Coroutines & Flow questions
These 8 are a sample. The full Coroutines & Flow bank is scored, tracks your progress, and explains every answer.
More Android interview topics
- Android Hilt interview questions
- Android Room interview questions
- Android Design Patterns interview questions
- Android Mobile System Design interview questions
- Android Coding Interview Patterns interview questions
- Android NDK interview questions
- Android Sensors interview questions
- Android Security interview questions
- Android Jetpack Compose interview questions
- Android Canvas & Animation interview questions
- Android CI/CD interview questions
- Android Git interview questions
- Android Unit Testing interview questions
- Android Kotlin interview questions
- Android Retrofit interview questions
- Android Architecture interview questions
- Android Android Framework interview questions
- Android Kotlin Multiplatform interview questions
- Android WorkManager & Background interview questions
- Android Performance & Memory interview questions