Three questions from the bank, with answers. The practice test draws different ones each time.
Question 1 · Jetpack Compose Lists · junior
What is the key performance advantage of LazyColumn over a standard Column with a vertical scroll modifier?
val userList = listOf("Alice", "Bob", "Charlie")
LazyColumn {
items(userList) { user ->
Text(text = user)
}
}
A.It efficiently renders only the visible items on the screen and recycles views as you scroll.
B.It automatically paginates data from a remote network database.
C.It acts as a static vertical column that cannot be scrolled.
D.It renders all items into memory immediately upon creation.
Show answer
A. It efficiently renders only the visible items on the screen and recycles views as you scroll.
LazyColumn only renders items currently visible on the screen plus a small buffer, recycling them as the user scrolls, similar to RecyclerView. A common misconception is that it renders all items in the list at once, which would cause performance issues for large datasets.
Question 2 · Jetpack Compose State · junior
What is the primary purpose of the remember function in Jetpack Compose?
val state = remember { mutableStateOf(0) }
A.It makes the state observable across different activities in the app.
B.It retains the state across recompositions of the composable function.
C.It retains the state across configuration changes like screen rotation.
D.It converts the state into a StateFlow for coroutine consumption.
Show answer
B. It retains the state across recompositions of the composable function.
remember stores objects in the Composition and retains them across recompositions. If remember is omitted, the state would be reset to 0 every time the composable function recomposes. A common misconception is that remember survives configuration changes like screen rotation, which requires rememberSaveable.
Question 3 · Lifecycle & Coroutines · junior
Why is repeatOnLifecycle(Lifecycle.State.STARTED) preferred for collecting flows in an Activity or Fragment?
A.It launches a coroutine only when the lifecycle is destroyed.
B.It collects the flow indefinitely without lifecycle awareness.
C.It restarts the activity whenever the UI state emits a new value.
D.It safely collects flows by starting when STARTED and cancelling when STOPPED.
Show answer
D. It safely collects flows by starting when STARTED and cancelling when STOPPED.
repeatOnLifecycle automatically cancels and restarts the block when the lifecycle moves between the specified state (STARTED) and STOPPED. This prevents resource leaks by stopping flow collection when the app goes to the background. A common trap is using launchWhenStarted, which can keep collecting flows even when the app is invisible.