AAD AAD Android Architecture & App Components 1 — Questions and Answers
Question 1: Which Android component serves as the primary entry point for user interaction and displays a single screen with a user interface?
- Service
- Activity (Correct answer)
- BroadcastReceiver
- ContentProvider
Correct answer: Activity
An Activity represents a single screen with a UI and is the primary entry point for user interaction in an Android app.
Question 2: Which Android component is designed to perform long-running background operations without a user interface?
- Fragment
- Activity
- Service (Correct answer)
- Intent
Correct answer: Service
A Service runs in the background to perform long-running operations without providing a user interface.
Question 3: In the Activity lifecycle, which method is called when the Activity is first created?
- onStart()
- onResume()
- onCreate() (Correct answer)
- onRestart()
Correct answer: onCreate()
onCreate() is the first lifecycle callback called when an Activity is created, where you initialize the UI and data.
Question 4: What is the primary purpose of an Intent in Android?
- To store persistent data
- To define UI layouts
- To schedule background tasks
- To facilitate communication between components (Correct answer)
Correct answer: To facilitate communication between components
An Intent is a messaging object used to request an action from another component, facilitating communication between Activities, Services, and BroadcastReceivers.
Question 5: Which Activity lifecycle method is called when the Activity becomes visible to the user but may not yet be in the foreground?
- onResume()
- onStart() (Correct answer)
- onRestart()
- onPause()
Correct answer: onStart()
onStart() is called when the Activity becomes visible to the user, before it enters the foreground interactive state.
Question 6: What is a Fragment in Android?
- A standalone app process
- A reusable UI portion that lives inside an Activity (Correct answer)
- A background service component
- A type of Intent
Correct answer: A reusable UI portion that lives inside an Activity
A Fragment is a reusable portion of your app's UI that has its own lifecycle and can be embedded in an Activity.
Which Android component serves as the primary entry point for user interaction and displays a single screen with a user interface?