0
0
Android Kotlinmobile~20 mins

Creating a new Android project in Android Kotlin - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Android Project Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
2:00remaining
What is the default launcher activity in a new Android project?
When you create a new Android project in Android Studio with the default settings, which activity is set as the launcher activity that opens first when the app starts?
AHomeActivity
BSplashActivity
CMainActivity
DLoginActivity
Attempts:
2 left
💡 Hint
Think about the activity Android Studio creates automatically for you.
lifecycle
intermediate
2:00remaining
What lifecycle method is called first when the app starts?
In the default MainActivity of a new Android project, which lifecycle method is called first when the app is launched?
AonCreate()
BonStart()
ConResume()
DonDestroy()
Attempts:
2 left
💡 Hint
This method is where you usually set your layout.
📝 Syntax
advanced
2:00remaining
Which Kotlin code snippet correctly sets the content view in MainActivity?
In the MainActivity.kt file of a new Android project, which code correctly sets the layout resource named activity_main as the content view?
Android Kotlin
class MainActivity : AppCompatActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    // Set content view here
  }
}
AsetContentView("activity_main")
BsetContentView(R.layout.activity_main)
CsetContentView(R.id.activity_main)
DsetContentView(layout.activity_main)
Attempts:
2 left
💡 Hint
The layout resource is accessed via R.layout.
navigation
advanced
2:00remaining
What happens if you forget to declare MainActivity in AndroidManifest.xml?
If you create MainActivity.kt but do not add it to AndroidManifest.xml, what will happen when you try to run the app?
AThe app crashes with ActivityNotFoundException at startup
BThe app runs but shows a blank screen
CThe app runs normally without issues
DThe app shows a compile-time error
Attempts:
2 left
💡 Hint
Android needs to know which activity to launch first.
🧠 Conceptual
expert
2:00remaining
Why does Android Studio create a Gradle build file in a new project?
When you create a new Android project, Android Studio generates build.gradle files. What is the main purpose of these Gradle files?
ATo define AndroidManifest.xml contents
BTo store user interface layouts
CTo write Kotlin code for activities
DTo manage project dependencies and build configurations
Attempts:
2 left
💡 Hint
Think about how the app knows which libraries to include and how to compile.