Challenge - 5 Problems
Composable Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
What is the output of this Composable function?
Consider this Kotlin Compose code snippet. What will be displayed on the screen?
Android Kotlin
import androidx.compose.material.Text import androidx.compose.runtime.Composable @Composable fun Greeting() { Text(text = "Hello Compose") }
Attempts:
2 left
💡 Hint
Look at what the Text composable does inside the Greeting function.
✗ Incorrect
The Greeting composable calls Text with the string 'Hello Compose', so the UI will show that text label.
❓ lifecycle
intermediate2:00remaining
When is a Composable function recomposed?
Given a Composable function with a state parameter, when does Compose re-run the function to update the UI?
Attempts:
2 left
💡 Hint
Think about what triggers UI updates in Compose.
✗ Incorrect
Compose re-executes Composable functions when the state they depend on changes, to update the UI accordingly.
📝 Syntax
advanced2:00remaining
Which option correctly defines a Composable function with a parameter?
Select the correct Kotlin Compose function syntax that takes a String parameter and displays it.
Attempts:
2 left
💡 Hint
Remember the correct placement of the @Composable annotation and parameter types.
✗ Incorrect
Option B correctly places @Composable before the function, declares the parameter type, and calls Text with text = message.
🔧 Debug
advanced2:00remaining
What error occurs with this Composable code?
Analyze this code snippet and identify the error it causes.
Android Kotlin
import androidx.compose.material.Text import androidx.compose.runtime.Composable @Composable fun MyText() { Text("Hello") }
Attempts:
2 left
💡 Hint
Check the Text composable parameter requirements.
✗ Incorrect
Text requires a named parameter 'text'. Passing a string without naming causes a compilation error.
🧠 Conceptual
expert2:00remaining
What is the main benefit of using Composable functions in Android development?
Choose the best explanation for why Composable functions are used in modern Android UI development.
Attempts:
2 left
💡 Hint
Think about how Compose handles UI and state.
✗ Incorrect
Composable functions let you describe UI declaratively and Compose handles efficient UI updates when state changes.