Kotlin Flow and StateFlow interview questions

Cold and hot streams, StateFlow and SharedFlow, operators, one-off events and safe collection from the UI.

5 quick facts

– interview-ready · 14 questions in this topic

– of 14 tried

Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.

Questions

  1. Cold vs hot flowsPredict
  2. StateFlow vs SharedFlowPredict
  3. stateIn and WhileSubscribed(5_000)Pick the fix
  4. One-off events from a ViewModelPick the fix
  5. map, filter and transformPredict
  6. Search-as-you-type with FlowPick the fix
  7. combine vs zipPredict
  8. flowOn and context preservationSpot the bug
  1. Handling errors in a FlowPredict
  2. Wrapping a listener with callbackFlowSpot the bug
  3. buffer, conflate and collectLatestPredict · timeline
  4. Why didn't my StateFlow update?Spot the bug
  5. LiveData vs StateFlowPick the fix
  6. ChannelsPredict

Practise this topic

Flashcards · 19

Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.

Quick quiz · 14 questions

One exercise per question, checked as you go. Needs JavaScript.

Mock interview · 2 sets

Timed, out loud, then tick what you covered. Needs JavaScript.

Fix this PR · 3 reviews

Review a diff like a senior: flag the lines you'd comment on. Needs JavaScript.

Quick facts

Recall the answer first, then tap Show to check.

Sources: Question outline adapted from Android-Interview-Questions by Mohsen Mirhoseini, licensed under Apache 2.0. We reorganised the questions, rewrote every answer and added new ones. Credits and license