Professional Documents
Culture Documents
Which method is called when an Activity is destroyed and removed from memory?
A. onCreate()
B. onPause()
C. onStop()
D. onDestroy()
Which method is called when an Activity is re-created after being destroyed and removed from
memory?
A. onCreate()
B. onPause()
C. onStop()
D. onRestart()
Chap 8
What is an Intent in Android?
A. A visual user interface focused on a single thing a user can do.
B. A way to make some of the application data available to other applications.
C. A message object that is used to communicate between components in an application.
D. A type of broadcast receiver that reacts to incoming messages.
How do you receive data from a previous Activity in the current Activity in Android?
A. By calling startActivity() method with the data as parameter.
B. By calling setResult() method with the data as parameter.
C. By using Intent extras to add the data to the Intent before starting the Activity.
D. By overriding the onActivityResult() method and extracting the data from the Intent.
How do you start an Activity and receive a result back from it in Android?
A. By calling startActivity() method and passing the data as parameter.
B. By calling setResult() method and passing the data as parameter.
C. By using Intent extras to add the data to the Intent before starting the Activity.
D. By calling startActivityForResult() method and waiting for the result in the onActivityResult()
method.
Chap 9
What is a RecyclerView in Android?
A) A layout that arranges views in a grid format
B) A view that displays a list of items in a vertical or horizontal scrollable list
C) A class that manages the lifecycle of an activity or fragment
D) A type of service that runs in the background
Answer: B
Which method should you call to add or remove items from a RecyclerView?
A) notifyDataSetChanged()
B) notifyItemChanged()
C) notifyItemInserted() and notifyItemRemoved()
D) notifyItemRangeChanged()
Answer: C
Chap 10:
Which method can be used to load an image into an ImageView in Android?
a) setImageResource()
b) setImageBitmap()
c) setImageDrawable()
d) All of the above
Which of the following is NOT a commonly used image file format in Android?
a) PNG
b) JPEG
c) GIF
d) MP4
Chap 11:
What are Android Permissions used for?
a) To make an app more user-friendly
b) To protect user privacy and security
c) To improve app performance
d) Both B and C
Answer: b) To protect user privacy and security
Which file in an Android app specifies the permissions required by the app?
a) AndroidManifest.xml
b) MainActivity.java
c) build.gradle
d) strings.xml
Answer: a) AndroidManifest.xml
What happens if an app requests a permission that the user has previously denied?
a) The permission is automatically granted without prompting the user again
b) The app cannot perform the action that requires the permission
c) The user is prompted again to grant the permission
d) The app is uninstalled from the device
Answer: c) The user is prompted again to grant the permission
What is the difference between a normal permission and a dangerous permission in Android?
a) There is no difference
b) Normal permissions do not require user approval, while dangerous permissions do
c) Dangerous permissions are only granted to system apps, while normal permissions can be granted
to any app
d) Dangerous permissions are only used for system-level operations, while normal permissions are
used for app-level operations
Answer: b) Normal permissions do not require user approval, while dangerous permissions do
Which of the following is NOT a best practice for handling Android permissions?
a) Explain to the user why the permission is necessary
b) Request all permissions at once to avoid multiple prompts
c) Handle permission requests in a graceful and user-friendly way
d) Respect the user's decision if they deny a permission request
Answer: b) Request all permissions at once to avoid multiple prompts
Chap 12:
What is an Android notification?
a) A pop-up message that appears on the device's lock screen
b) A message that appears in the device's notification shade
c) A message that appears in the app's main interface
d) Both A and B
Answer: d) Both A and B
Chap 13:
What is the purpose of shared preferences in Android?
A) To store small amounts of data as key-value pairs
B) To store large amounts of structured data in a SQLite database
C) To store files and directories in internal or external storage
D) To store data in a cloud-based service
Answer: A) To store small amounts of data as key-value pairs
Which method can be used to read from a file in internal storage in Android?
A) openFileOutput()
B) openFileInput()
C) getExternalFilesDir()
D) getFilesDir()
Answer: B) openFileInput()
Which method can be used to delete a file from internal storage in Android?
A) deleteFile()
B) getFilesDir()
C) openFileInput()
D) openFileOutput()
Answer: A) deleteFile()
Chap 14
What is a content provider in Android?
A) A mechanism for managing application resources
B) A component that allows data sharing between applications
C) A layout container for organizing user interface elements
D) A service that runs in the background indefinitely
Answer: B) A component that allows data sharing between applications
Which content provider is used to store and retrieve system settings in Android?
A) ContactsContract
B) Settings.System
C) MediaStore
D) CallLog.Calls
Answer: B) Settings.System
Which content provider is used to store and retrieve media files in Android?
A) ContactsContract
B) Settings.System
C) MediaStore
D) CallLog.Calls
Answer: C) MediaStore
Which content provider is used to store and retrieve contact information in Android?
A) ContactsContract
B) Settings.System
C) MediaStore
D) CallLog.Calls
Answer: A) ContactsContract
Chap 16
What is multithreading?
A. Running multiple instances of an app on a device
B. Running multiple tasks simultaneously within an app
C. Running an app in the background
D. Running an app on multiple devices simultaneously
Answer: B
Which of the following is NOT true about the main (UI) thread in Android?
A. It handles all user interface interactions
B. It should be used for long-running tasks
C. It can be blocked by long-running tasks, causing the app to become unresponsive
D. It should only be used for short, lightweight tasks
Answer: B
Which of the following is a correct way to start a new thread in an Android app?
A. Create a new instance of the Thread class and call its start() method
B. Call the run() method on the current thread
C. Create a new instance of the Runnable interface and call its start() method
D. Create a new instance of the Thread class and call its run() method
Answer: A
Which of the following methods is used to update the UI from a background thread in Android?
A. runOnUiThread()
B. post()
C. sendBroadcast()
D. start()
Answer: A
Chap 17
What is a Fragment in Android?
A. A part of an activity that can be reused in different activities.
B. A separate standalone activity in Android.
C. A component used to communicate with other applications.
D. A widget used for displaying images and text.
Answer: A. A part of an activity that can be reused in different activities.