Recall & Review
beginner
What is a Composable function in Jetpack Compose?
A Composable function is a special Kotlin function annotated with @Composable that describes part of the app's UI. It can be combined with other composables to build the interface.
Click to reveal answer
beginner
How do you mark a function as composable in Kotlin?
By adding the @Composable annotation before the function definition.
Click to reveal answer
intermediate
Why should composable functions be side-effect free and idempotent?
Because composable functions can be called many times during UI updates, they should not change data or state directly and should always produce the same UI output for the same inputs.
Click to reveal answer
beginner
What is the role of the
setContent function in an Android app using Compose?It sets the UI content of an activity by calling composable functions inside it, replacing the traditional XML layout inflation.
Click to reveal answer
beginner
Can composable functions call other composable functions?
Yes, composable functions can call other composable functions to build complex UI by combining smaller UI pieces.
Click to reveal answer
Which annotation marks a function as composable in Jetpack Compose?
✗ Incorrect
The @Composable annotation tells the compiler that the function describes UI and can be used in Compose.
What does a composable function return?
✗ Incorrect
Composable functions return Unit and describe UI declaratively instead of returning View objects.
Which function is used to set the UI content in a Compose-based Android activity?
✗ Incorrect
setContent() replaces setContentView() in Compose to set composable UI content.
Why should composable functions avoid side effects?
✗ Incorrect
Composable functions may be called many times during UI updates, so side effects can cause bugs or inconsistent UI.
Can composable functions have parameters?
✗ Incorrect
Composable functions can take parameters to customize the UI they display.
Explain what a composable function is and how it is used in Jetpack Compose.
Think about how UI pieces are built in Compose.
You got /5 concepts.
Describe why composable functions should be side-effect free and what could happen if they are not.
Consider how UI updates happen in Compose.
You got /4 concepts.