Qtr No. 213, New Town Yehlanka Indore 454775
You are developing an app using Jetpack Compose, and you need to understand how the execution flow of States happens in Compose. You want to ensure that you have a clear understanding of how States are updated and propagated in order to write efficient and bug-free code.
@Composable
fun Counter() {
var count by remember { mutableStateOf(0) }
Button(onClick = { count++ }) {
Text(text = "Increment")
}
Text(text = "Count: $count")
}
Based on the code above, answer the following question:
How does the execution flow of states happen in the Counter composable function when the button is clicked ?
The mutableStateOf(0) function is called every time the button is clicked, updating the state immediately.
The remember function ensures that the mutableStateOf(0) is only called once during the initial composition.
The state count is automatically updated and recomposition of the composable function is triggered when the button is clicked.
The state count is only updated after the composable function finishes executing.
To get all Infosys Certified Android Specialist Exam questions Join Group https://bit.ly/infy_premium_group
We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.
Qtr No. 213, New Town Yehlanka Indore 454775
admin@prepflix.in