Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare a basic Activity class in Kotlin.
Android Kotlin
class MainActivity : [1]() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Fragment or Service instead of AppCompatActivity.
Forgetting to extend any class.
✗ Incorrect
The MainActivity class must extend AppCompatActivity to be a valid Activity.
2fill in blank
mediumComplete the code to set the layout resource for the Activity.
Android Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
[1](R.layout.activity_main)
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using inflate or setLayout which are not Activity methods.
Calling findViewById instead of setting the layout.
✗ Incorrect
The method setContentView sets the UI layout for the Activity.
3fill in blank
hardFix the error in the Activity lifecycle method override.
Android Kotlin
override fun onStart() {
super.[1]()
// Additional code here
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling super.onCreate() inside onStart.
Forgetting the super call entirely.
✗ Incorrect
When overriding onStart, call super.onStart() to maintain lifecycle behavior.
4fill in blank
hardFill both blanks to start a new Activity from the current one.
Android Kotlin
val intent = Intent(this, [1]::class.java) [2](intent)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using finish() instead of startActivity().
Using the wrong Activity class in the Intent.
✗ Incorrect
To start a new Activity, create an Intent with the target Activity class and call startActivity with it.
5fill in blank
hardFill all three blanks to pass data to another Activity using Intent extras.
Android Kotlin
val intent = Intent(this, [1]::class.java) intent.[2]("username", "Alice") [3](intent)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getExtra instead of putExtra.
Forgetting to call startActivity.
Passing wrong Activity class.
✗ Incorrect
Use putExtra to add data to the Intent, then call startActivity to launch the target Activity.