MCQs / Computer Science / Lab: Multiple Activities and Navigation
Lab: Multiple Activities and Navigation MCQs — Computer Science 14 multiple-choice questions on Lab: Multiple Activities and Navigation from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.
1. When you add an activity using New → Activity in Android Studio, it automatically: Deletes MainActivity Creates a fragment Creates the class, its layout and the manifest entry Publishes the app Answer: C) Creates the class, its layout and the manifest entry
Explanation: The wizard creates all three pieces.
Discuss this question
2. Which code creates an explicit intent for SecondActivity in Kotlin? startActivity(SecondActivity) Intent(this, SecondActivity::class.java) Intent("SecondActivity") Intent(Intent.ACTIONVIEW) Answer: B) Intent(this, SecondActivity::class.java)
Explanation: The constructor takes a context and the target class.
Discuss this question
3. Extras are stored inside the intent as a: Bundle of key–value pairs SQLite table JSON file SharedPreferences file Answer: A) Bundle of key–value pairs
Explanation: Intent extras are kept in a Bundle.
Discuss this question
4. The modern replacement for startActivityForResult() is: registerForActivityResult() with an ActivityResultLauncher onActivityResult() only setResult() alone startService() Answer: A) registerForActivityResult() with an ActivityResultLauncher
Explanation: The Activity Result API replaces the deprecated startActivityForResult.
Discuss this question
5. Which method closes the current activity and returns to the previous one? finish() exit() close() stop() Answer: A) finish()
Explanation: finish() destroys the activity and pops it from the back stack.
Discuss this question
6. android:exported="false" on SecondActivity means: Other apps cannot start this activity directly The activity is exported to iOS The activity cannot be opened at all The activity is hidden from the launcher only Answer: A) Other apps cannot start this activity directly
Explanation: exported=false restricts launching to components of the same app.
Discuss this question
7. When the user returns to MainActivity from SecondActivity, MainActivity calls: onCreate() only onPause() onDestroy() onRestart(), onStart(), onResume() Answer: D) onRestart(), onStart(), onResume()
Explanation: A stopped activity restarts when it becomes visible again.
Discuss this question
8. An intent that names the exact class to start is called: Explicit intent Implicit intent Sticky intent Pending intent Answer: A) Explicit intent
Explanation: Explicit intents specify the target component by class.
Discuss this question
9. Which method sends a result back to the calling activity? putExtra(RESULT) returnData() setResult(RESULTOK, intent) sendBroadcast() Answer: C) setResult(RESULTOK, intent)
Explanation: setResult with a result code and data intent, followed by finish().
Discuss this question
10. A new activity that is not declared in the manifest causes: Nothing; it works normally The app to open the browser A compile warning only ActivityNotFoundException at run time Answer: D) ActivityNotFoundException at run time
Explanation: Every activity must be registered in AndroidManifest.xml.
Discuss this question
11. The manifest attribute that enables the Up button to return to MainActivity is: android:theme android:taskAffinity android:parentActivityName android:launchMode Answer: C) android:parentActivityName
Explanation: parentActivityName defines the logical parent for Up navigation.
Discuss this question
12. Data is attached to an intent using: addData() putExtra() setText() sendData() Answer: B) putExtra()
Explanation: putExtra(key, value) adds extras to the intent.
Discuss this question
13. When SecondActivity opens on top of MainActivity, MainActivity normally goes through: onPause() then onStop() onRestart() only onDestroy() onCreate() again Answer: A) onPause() then onStop()
Explanation: The first activity becomes hidden, so it is paused and stopped but stays on the back stack.
Discuss this question
14. In SecondActivity, the passed name is read with: savedInstanceState.getName() intent.putExtra("NAME") getString("NAME") intent.getStringExtra("NAME") Answer: D) intent.getStringExtra("NAME")
Explanation: getStringExtra(key) reads a string extra from the starting intent.
Discuss this question
Practise Lab: Multiple Activities and Navigation MCQs
More Computer Science chapters