Jetpack Compose interview questions
State, recomposition, stability, side effects, lists, modifiers and navigation: how Compose really decides what to redraw.
– interview-ready · 22 questions in this topic
– of 22 tried
Saved on this device. Interview-ready means you got it right on two different days. Guesses and hints count for less.
Questions
- Compose vs the View systemPick the fix
- What triggers recomposition?Predict
- remember vs rememberSaveablePredict
- State hoistingPick the fix
- Stability and skippingPredict
- Deferring state readsPick the fix
- derivedStateOfPick the fix
- LaunchedEffect and its keysPredict
- DisposableEffectFill the blank
- rememberCoroutineScopePick the fix
- rememberUpdatedStateSpot the bug
- Keys in LazyColumnPredict
- Why modifier order mattersPredict
- CompositionLocalPick the fix
- collectAsStateWithLifecycleFill the blank
- Navigation in ComposePick the fix
- Previews that scaleOrder the steps
- Slot APIsSpot the bug
- State lists and mutationSpot the bug
- Compose and Views togetherPick the fix
- Strong skipping modePredict
- Choosing an animation APIPick the fix
Practise this topic
Flashcards · 28
Flip, then say if you knew it. Needs JavaScript; every answer is also on its question page.
Quick quiz · 22 questions
One exercise per question, checked as you go. Needs JavaScript.
Mock interview · 4 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.
Compose phases
Compose renders a frame in three phases: composition, layout and drawing.
@Immutable vs @Stable
@Immutable promises a value never changes; @Stable promises changes are notified through Compose state.
Modifier.animateItem()
animateItem() on a LazyColumn item animates insertions, removals and moves; it needs item keys.
Compose compiler plugin
Since Kotlin 2.0, the Compose compiler ships with Kotlin and is applied with the org.jetbrains.kotlin.plugin.compose Gradle plugin.
SideEffect
SideEffect { } runs after every successful recomposition, for publishing Compose state to non-Compose code.
produceState
produceState launches a coroutine that turns non-Compose data into a State and cancels it when it leaves composition.
Printable cheat sheet · Review your weak spots in this topic
Share your progress
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