Skip to content
tezvyn:

Top 30 Jetpack compose Interview Questions and Answers

30 multiple-choice questions on Jetpack compose, drawn from 30 bites out of the 33 tagged Jetpack compose on Tezvyn. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.

30 questions. Pick an answer, or open “Show the answer” to read it.

Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.

  1. Question 1 of 30

    If a `mutableStateOf` variable is declared inside a composable without `remember`, what happens when the UI recomposes?

    Show the answer

    Answer: d · The variable is reset to its initial value, losing any previous updates.

    Composable functions are re-invoked on recomposition, so any local variable is re-initialized. `remember` caches the state object in the Composition, preventing it from being reset. Without it, the state is lost.

    Read the full bite: What is the purpose of `remember` in Jetpack Compose?

  2. Question 2 of 30

    What is the main purpose of using the remember function in a Jetpack Compose Composable?

    Show the answer

    Answer: c · To ensure that a local variable's value is preserved across recompositions.

    The remember function stores an object in the Composition's memory, preventing local variables from being re-initialized on every recomposition. Option D describes rememberSaveable, while Option A describes the role of mutableStateOf in making state observable.

    Read the full bite: What is the purpose of the `remember` function in Compose?

  3. Question 3 of 30

    What is the primary purpose of the `Modifier` parameter in Jetpack Compose?

    Show the answer

    Answer: b · To configure a composable's size, spacing, appearance, and behavior.

    A Modifier is the standard way to configure a composable's size, layout, appearance, and behavior. While it can affect appearance (distractor D), its role is much broader, and global theme styles are typically handled by `MaterialTheme`.

    Read the full bite: How do you arrange UI elements in Jetpack Compose?

  4. Question 4 of 30

    Which Jetpack Compose elements are primarily used to display a profile picture above a name, centered horizontally, within a card with a background and padding?

    Show the answer

    Answer: b · Column for vertical layout, Modifier for background/padding, and horizontalAlignment for centering.

    Column is the correct composable for arranging elements vertically. Modifier is the standard and idiomatic way to apply properties like background and padding. horizontalAlignment on the Column centers its children horizontally, while Row is used for horizontal arrangements.

    Read the full bite: How to arrange UI elements in Jetpack Compose?

  5. Question 5 of 30

    When a state object is updated, how does Jetpack Compose efficiently perform recomposition?

    Show the answer

    Answer: c · It re-runs only the composables that read the changed state, potentially skipping children with unchanged, stable inputs.

    Compose's efficiency comes from smart, scoped recomposition. It re-runs only the functions that read the changed state and can skip re-running child composables if their inputs are stable and unchanged. Redrawing the entire tree is a common misconception from older UI toolkits.

    Read the full bite: Explain Recomposition in Jetpack Compose

  6. Question 6 of 30

    Which statement accurately describes how Jetpack Compose primarily optimizes recomposition to avoid unnecessary UI updates?

    Show the answer

    Answer: b · It skips the execution of a composable function and its children if all its input parameters are stable and have not changed since the last execution.

    The card states that Compose's primary optimization is 'skipping': if all parameters are 'stable' and unchanged, Compose skips re-running the function and its children. Option C describes a general diffing algorithm, which is not Compose's core mechanism for skipping function execution.

    Read the full bite: Explain Recomposition in Jetpack Compose

  7. Question 7 of 30

    What is the primary architectural goal achieved by applying state hoisting in Jetpack Compose?

    Show the answer

    Answer: d · To make composables stateless, thereby enhancing their reusability and testability.

    State hoisting's primary goal is to create stateless composables, which significantly improves their reusability and testability by making them 'dumb' components. Option B describes the opposite of state hoisting's intent for the child composable, while Option C refers to state persistence, a related but distinct concern.

    Read the full bite: Describe state hoisting in Jetpack Compose.

  8. Question 8 of 30

    What is the primary architectural benefit of applying the state hoisting pattern to a composable?

    Show the answer

    Answer: d · It makes the composable stateless and reusable by decoupling it from how its state is stored and managed.

    State hoisting makes a composable stateless by moving state management to its parent. This decoupling is key to making the component reusable and easier to test in isolation. While state is often hoisted *to* a ViewModel, the pattern itself is about the parent-child relationship, not just about using a ViewModel.

    Read the full bite: Describe the state hoisting pattern in Compose

  9. Question 9 of 30

    To fetch data from a network API exactly once when a composable first appears, which approach is correct and safe?

    Show the answer

    Answer: b · Wrap the suspend function call inside a `LaunchedEffect(Unit)` block.

    LaunchedEffect(Unit) is correct because it creates a coroutine that runs only once and is automatically cancelled on exit. Using `rememberCoroutineScope` directly in the composable body is a major error that launches a new coroutine on every recomposition.

    Read the full bite: Which Compose side-effect for a one-time coroutine action?

  10. Question 10 of 30

    To perform a coroutine action only once when a composable first enters the composition, which handler is most appropriate?

    Show the answer

    Answer: c · LaunchedEffect(Unit) { ... }

    LaunchedEffect with a constant key like Unit ensures the coroutine runs only once when the composable first enters the composition. Directly calling rememberCoroutineScope.launch would relaunch the coroutine on every recomposition.

    Read the full bite: Which side-effect handler for a one-time coroutine action in Compose?

  11. Question 11 of 30

    You find a long list implemented with a `Column` and a `verticalScroll` modifier. What is the primary performance issue with this approach for large datasets?

    Show the answer

    Answer: a · It composes every item in the list at once, regardless of visibility, causing high memory usage and slow initial rendering.

    The correct answer is B because a scrollable `Column` composes all its children upfront, which is a major performance trap for large lists. Option B is a tempting distractor, but the fundamental bottleneck is the composition strategy, not gesture handling.

    Read the full bite: How to implement efficient large lists in Jetpack Compose?

  12. Question 12 of 30

    To display a list of 1,000 items efficiently in Jetpack Compose, which approach best prevents UI freezes and high memory usage?

    Show the answer

    Answer: b · Implementing a LazyColumn with the items DSL.

    LazyColumn virtualizes its content, meaning it only composes and measures items that are currently visible, ensuring optimal performance for large lists. A Column with a verticalScroll modifier makes content scrollable but still composes all items at once, leading to performance issues.

    Read the full bite: Implement an efficient list in Jetpack Compose

  13. Question 13 of 30

    A Composable displays a user's input in a text field. Which state management approach ensures the input persists across a device rotation and why?

    Show the answer

    Answer: a · Using rememberSaveable because it leverages the Android Bundle mechanism to store state across activity recreation.

    The correct answer is B. rememberSaveable is specifically designed to persist state across activity recreation, such as device rotation or process death, by utilizing the Android Bundle mechanism. Option C is incorrect because remember only survives recompositions and is lost when the activity is recreated, which happens during a device rotation.

    Read the full bite: remember vs. rememberSaveable: When and Why to Use Each

  14. Question 14 of 30

    A user is typing their email into a text field. To ensure the text is not lost if the user rotates their device, which state-holding approach is most appropriate?

    Show the answer

    Answer: c · Use `rememberSaveable` because it persists state across configuration changes by saving it to the system's `Bundle`.

    `rememberSaveable` is correct because it uses the `Bundle` mechanism to survive configuration changes like screen rotation. In contrast, `remember` alone is insufficient as its state is lost when the Activity is recreated during rotation.

    Read the full bite: `remember` vs. `rememberSaveable`: When and why to use each?

  15. Question 15 of 30

    When diagnosing excessive recomposition in Compose, which tool is most crucial for identifying why a composable's parameters are preventing skipping?

    Show the answer

    Answer: c · The Compose Compiler Metrics report detailing parameter stability.

    The Compose Compiler Metrics report explicitly details which parameters are marked as stable or unstable, directly explaining why a composable might not be skippable. While the Layout Inspector shows that a composable is recomposing excessively, it does not reveal the underlying reason for its instability.

    Read the full bite: How do you diagnose and fix excessive recomposition in Jetpack Compose?

  16. Question 16 of 30

    You've used the Layout Inspector and found a composable with a high recomposition count. What is the most effective next step to diagnose the root cause?

    Show the answer

    Answer: d · Enable and analyze the Compose compiler reports to check for unstable parameters or unskippable composables.

    The compiler reports provide a definitive diagnosis of stability issues, which is the root cause of unskippable composables. Applying fixes like using `ImmutableList` or `remember` without this diagnosis is premature.

    Read the full bite: How do you diagnose and fix excessive recomposition in Jetpack Compose?

  17. Question 17 of 30

    Which of the following is a critical guideline for writing Composable functions to ensure optimal performance?

    Show the answer

    Answer: d · Avoid placing expensive operations like network requests or heavy computations directly inside them.

    The card explicitly states that heavy computations or side-effects like network requests should not be placed directly inside composables because their frequent recomposition can cause severe performance issues. Option C is incorrect because business logic and heavy operations should be handled outside the composable to maintain UI responsiveness.

    Read the full bite: Composable Functions: Building UI with Kotlin Functions

  18. Question 18 of 30

    What is identified as the biggest mistake when building UIs with Compose layouts?

    Show the answer

    Answer: b · Failing to analyze the design and break it into reusable components before coding.

    The card explicitly states, "The biggest mistake is failing to analyze the design first. If you don't break the UI down into a hierarchy of smaller, reusable composables, you will end up with a monolithic, hard-to-manage function." Option A, while potentially leading to less efficient code in some cases, is not framed as the primary architectural pitfall.

    Read the full bite: Compose Layouts: Build UI by Describing It

  19. Question 19 of 30

    For which purpose should you typically avoid using a Modifier in Jetpack Compose?

    Show the answer

    Answer: d · Defining the text content displayed by a Text composable.

    The card states, "Do not use Modifiers to pass essential data that defines a Composable's content. For instance, the string for a Text composable... are passed as direct parameters, not through a Modifier." The other options are all common and appropriate uses for Modifiers.

    Read the full bite: Jetpack Compose Modifiers: Styling Your UI

  20. Question 20 of 30

    What is the primary advantage of employing "state hoisting" in Jetpack Compose?

    Show the answer

    Answer: d · It makes composables more reusable and testable by centralizing state management in parent components.

    State hoisting makes composables stateless, reusable, and easier to test because their behavior is controlled externally by a parent. Option C describes the opposite, where a composable manages its own state, which makes it less reusable and harder to test.

    Read the full bite: State in Jetpack Compose: The UI's Memory

  21. Question 21 of 30

    Which event directly causes Jetpack Compose to initiate a recomposition for a specific part of the UI?

    Show the answer

    Answer: d · A State object that a Composable function is observing has its value changed.

    Recomposition is automatically triggered when a State object that a composable reads is updated. Developers do not manually call a recompose function; instead, Compose intelligently re-runs only the composables dependent on the changed state, avoiding a full screen refresh.

    Read the full bite: Recomposition: Smart UI Updates in Compose

  22. Question 22 of 30

    What is the primary reason to choose a LazyColumn or LazyRow over a standard Column/Row for displaying a list in Jetpack Compose?

    Show the answer

    Answer: d · To efficiently manage memory and performance by rendering only visible items and recycling composables.

    Lazy layouts are designed to efficiently handle long lists by composing and rendering only the items currently visible on screen, plus a small buffer, and recycling composables. This prevents memory issues and UI freezes that would occur if all items were rendered at once. Option B is incorrect as lazy layouts specifically avoid pre-composing all items.

    Read the full bite: Lazy Layouts: Compose's Answer to Efficient Lists

  23. Question 23 of 30

    What is the fundamental concept guiding screen transitions in Navigation in Compose?

    Show the answer

    Answer: d · Screens are represented as state, and navigation occurs by changing the current route.

    The card explicitly states, "Treat your app's screens like a state machine. Each screen is a composable function identified by a unique string called a 'route'. Navigation is simply the act of changing the current route state." Option C is incorrect because Compose Navigation replaces the fragment-based system.

    Read the full bite: Navigation in Compose

  24. Question 24 of 30

    What is the primary motivation for using interoperability APIs like AndroidView and ComposeView?

    Show the answer

    Answer: c · To facilitate a phased migration of an existing application from the View system to Jetpack Compose.

    The card states these APIs exist to allow for a "gradual, piece-by-piece migration" of existing applications. While performance can be a factor, it's not the primary motivation, and state synchronization is explicitly noted as a "footgun" requiring careful management, not an automatic benefit.

    Read the full bite: Using Android Views in Compose (and Vice Versa)

  25. Question 25 of 30

    Which scenario most appropriately utilizes a Compose side-effect API?

    Show the answer

    Answer: a · Triggering a network request to fetch data when a screen first appears.

    Fetching data is a non-UI action that needs to be tied to the composable's lifecycle, preventing unpredictable execution during recomposition, which is the purpose of side-effect APIs. The other options describe UI calculations or derived state that should be handled directly within the composable's body or with derivedStateOf, not with side-effects.

    Read the full bite: Compose Side-Effects: Escaping the Pure Function

  26. Question 26 of 30

    Which scenario best justifies the use of CompositionLocal in a Jetpack Compose application?

    Show the answer

    Answer: d · Providing a global analytics client instance to various deeply nested composables without explicit parameter passing.

    CompositionLocal is ideal for ambient, semi-static data like a singleton service that needs to be accessed by many composables in a subtree, avoiding 'prop drilling'. Using it for mutable state or primary data dependencies (options A and C) is discouraged as it hides dependencies and complicates testing. Option C describes a side effect, not the primary justification for its use.

    Read the full bite: CompositionLocal: Implicitly Pass Data Down the UI Tree

  27. Question 27 of 30

    Which of the following scenarios is LEAST suitable for a Compose UI test?

    Show the answer

    Answer: a · Confirming that a Button composable from the Material library correctly triggers its onClick lambda when tapped.

    The card explicitly advises against testing the behavior of standard library composables, as this is trusting the framework's implementation. Other options describe valid scenarios for Compose UI tests, focusing on application-specific UI logic and state changes.

    Read the full bite: Compose UI Testing: Find Nodes, Assert State, Perform Actions

  28. Question 28 of 30

    Which statement best describes the primary function of Android's UI layer?

    Show the answer

    Answer: c · To display application data to the user and forward user interactions to underlying logic.

    The UI layer's primary role is to display data to the user and send user input to the ViewModel for processing by other layers. It does not handle data fetching, storage, or complex business logic itself, which are responsibilities of the data and domain layers.

    Read the full bite: Android's UI Layer: Displaying Data, Handling Events

  29. Question 29 of 30

    Which mechanism primarily enables Jetpack Compose's declarative, hierarchical, and swappable theming system?

    Show the answer

    Answer: b · CompositionLocal implicitly providing design tokens down the UI tree.

    CompositionLocal is the core mechanism that allows theme values to be implicitly passed down the composable tree, acting as a dependency injection system for design tokens. This enables hierarchical overrides and easy theme swapping, unlike global singletons which lack hierarchical scoping, or explicit parameter passing which is cumbersome.

    Read the full bite: Jetpack Compose Theming for Design Systems

  30. Question 30 of 30

    What is the fundamental shift in mental model for designing adaptive UIs for foldables?

    Show the answer

    Answer: c · Treating the device as a fluid container that reflows based on physical "posture."

    The core idea for foldables is to think in "postures" (folded, unfolded, semi-folded) rather than just screen sizes. Option A is a common misconception, treating a foldable solely as a large tablet, which the card identifies as a "footgun."

    Read the full bite: Adaptive UI for Foldables: Thinking in Postures

Could you explain these out loud?

That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon