Sample questions
Question 1Easy
Which layout places children vertically?
- Box
- Row
- Spacer
- Column
Answer: D. Column
Explanation
Row places horizontally; Box stacks children on top of each other.
Step-by-step solution
- Column arranges children vertically.
- Row arranges them horizontally.
- Box stacks them on top of each other.
Why the other options are wrong
- A. Box stacks children in layers.
- B. Row places children side by side.
- C. Spacer only adds empty space.
Question 2Easy
Which composable displays text?
- TextView
- Label
- Text
- Span
Answer: C. Text
Explanation
Text("Hello") draws a string; TextView belongs to the old View system.
Step-by-step solution
- Compose UI is built from composable functions.
- Text("Hello") shows text.
- TextView is the older View-system widget.
Why the other options are wrong
- A. TextView belongs to the XML View system, not Compose.
- B. Label is not a Compose composable.
- D. Span is an HTML tag.
Tip: Compose names drop 'View': TextView -> Text.
Question 3Easy
Which composable is clickable and runs code in its onClick lambda?
- Divider
- Button
- Column
- Spacer
Answer: B. Button
Explanation
Button(onClick = { ... }) { Text("OK") }.
Step-by-step solution
- Button(onClick = { ... }) { Text("OK") } runs the lambda on tap.
- Divider, Column and Spacer are layout or decoration composables.
- They do not have an onClick parameter.
Why the other options are wrong
- A. Divider just draws a line.
- C. Column arranges children vertically; it is not clickable by itself.
- D. Spacer only adds empty space.
Tip: Tap action = onClick lambda.
Question 4Easy
Recomposition in Compose means:
- Restarting the Activity
- Reinstalling the app
- Re-running on state change
- Recompiling the app
Answer: C. Re-running on state change
Explanation
Compose re-invokes affected composables to update the UI.
Step-by-step solution
- Compose remembers which state each composable reads.
- When that state changes, Compose re-runs those composables.
- It updates only what changed.
Why the other options are wrong
- A. The Activity is not restarted.
- B. Nothing is reinstalled.
- D. Nothing is recompiled; it happens at runtime.
Question 5Medium
A TextField in Compose shows typed characters only if:
- You use a
ViewModel - Its state is updated
- It is inside a
LazyColumn - You call
invalidate()
Answer: B. Its state is updated
Explanation
TextField is controlled: it displays value, and you must update that state in onValueChange.
Step-by-step solution
- TextField shows whatever value it is given.
- Typing calls onValueChange with the new text.
- If the state is not updated, the old value is shown again.
Why the other options are wrong
- A. Local state works too.
- C. Containers do not matter.
- D. Compose has no invalidate().
Question 6Medium
Why is remember { mutableStateOf(0) } used instead of just mutableStateOf(0) inside a composable?
- To save it to disk
- To survive recomposition
- To make the value a constant
- To run it on a background thread
Answer: B. To survive recomposition
Explanation
Without remember, a new state object would be created each time the composable re-runs, resetting the value.
Step-by-step solution
- A composable body runs again on every recomposition.
- Without remember, mutableStateOf(0) would create a new 0 each time.
- remember keeps the same state object across recompositions.
Why the other options are wrong
- A. remember holds memory only, not disk.
- C. The value can still change.
- D. Threading is unrelated.
Question 7Medium
In a Column, which parameter controls vertical spacing of children such as Arrangement.spacedBy(8.dp)?
- contentAlignment
- modifier.weight
- verticalArrangement
- horizontalAlignment
Answer: C. verticalArrangement
Explanation
Arrangement works along the main axis; Alignment along the cross axis.
Step-by-step solution
- In a Column, the main axis is vertical.
- verticalArrangement controls main-axis spacing.
- Arrangement.spacedBy(8.dp) puts 8 dp between children.
Why the other options are wrong
- A. contentAlignment belongs to Box.
- B. weight shares leftover space.
- D. horizontalAlignment controls the cross axis.
Question 8Medium
Which annotation shows a composable in Android Studio's design preview?
- @Sample
- @Display
- @Design
- @Preview
Answer: D. @Preview
Explanation
@Preview functions render in the IDE without running the app.
Step-by-step solution
- @Preview marks a composable for Android Studio's preview pane.
- It renders without running the app.
- You can set device size, theme and more.
Why the other options are wrong
- A. @Sample is not a Compose preview annotation.
- B. @Display does not exist for this.
- C. @Design does not exist for this.
Question 9Hard
Why should composable functions avoid side effects such as writing to a database directly in their body?
- It slows down the compiler
- They may re-run unpredictably
- Databases are blocked in Compose
- Composables cannot call Kotlin code
Answer: B. They may re-run unpredictably
Explanation
Side effects belong in effect handlers (LaunchedEffect etc.) or in the ViewModel.
Step-by-step solution
- Compose may re-run a composable often and in any order.
- It may also skip or cancel compositions.
- Side effects in the body could run many times or at the wrong moment.
Why the other options are wrong
- A. Compile speed is unrelated.
- C. Databases are not blocked.
- D. Composables can call normal Kotlin code.
Question 10Hard
Two modifiers are applied: Modifier.padding(16.dp).background(Color.Red) versus Modifier.background(Color.Red).padding(16.dp). What differs?
- Nothing; order never matters
- The first throws an exception
- The second has no padding
- Where the padding sits
Answer: D. Where the padding sits
Explanation
Modifiers apply in order; padding before background shrinks the area that gets painted.
Step-by-step solution
- Modifiers apply in order, from outside in.
- padding then background: the padding sits outside the red area.
- background then padding: red fills the padded area too.
Why the other options are wrong
- A. Modifier order matters.
- B. Both are valid.
- C. Both have padding; it just sits in a different place.
Practise all 25 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →