0
0
Android Kotlinmobile~20 mins

Recomposition concept in Android Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Recomposition Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What triggers recomposition in Jetpack Compose?
In Jetpack Compose, which of the following changes will cause a composable function to recompose?
AChanging a local variable inside the composable without State
BChanging a variable declared outside the composable but not observed
CModifying a parameter passed as a constant value
DA change in a State variable used inside the composable
Attempts:
2 left
💡 Hint
Think about what Compose observes to know when to update the UI.
lifecycle
intermediate
2:00remaining
How does recomposition affect performance?
Which statement best describes how recomposition impacts app performance in Jetpack Compose?
ARecomposition always recreates the entire UI tree, causing slow performance
BRecomposition freezes the UI until all composables finish rendering
CRecomposition only updates the parts of the UI that depend on changed State, improving efficiency
DRecomposition disables user input during the update process
Attempts:
2 left
💡 Hint
Think about how Compose optimizes UI updates.
🔧 Debug
advanced
2:00remaining
Why does this composable not recompose when State changes?
Consider this code snippet: @Composable fun Greeting(name: String) { Text(text = "Hello, $name!") } val userName = mutableStateOf("Alice") // In UI Greeting(name = userName.value) Why might the UI not update when userName.value changes?
ABecause Greeting is not marked with @Composable
BBecause userName is not passed as a State object, only its value is passed
CBecause mutableStateOf does not trigger recomposition
DBecause Text composable does not update on parameter changes
Attempts:
2 left
💡 Hint
Think about how Compose tracks State changes through parameters.
🧠 Conceptual
advanced
2:00remaining
What is the role of remember in recomposition?
In Jetpack Compose, what does the remember function do during recomposition?
AIt stores a value across recompositions to avoid resetting it
BIt forces recomposition to happen immediately
CIt disables recomposition for the composable
DIt clears all State variables when recomposition occurs
Attempts:
2 left
💡 Hint
Think about how to keep values stable during UI updates.
navigation
expert
2:00remaining
How does recomposition interact with navigation state?
In a Jetpack Compose app using Navigation Compose, what happens to composables when navigating between screens regarding recomposition?
AComposables of the previous screen are disposed and do not recompose when navigating away
BAll composables in the app recompose on every navigation event
CNavigation Compose disables recomposition to improve speed
DComposables keep their State but never recompose after navigation
Attempts:
2 left
💡 Hint
Consider the lifecycle of composables in navigation stacks.