MCQs / Computer Science / Threading and Publishing Android Applications
Threading and Publishing Android Applications MCQs — Computer Science 34 multiple-choice questions on Threading and Publishing Android Applications 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. Which type is used to expose a continuously updated value from a ViewModel to the UI? Intent Bundle StateFlow (or LiveData) Cursor Answer: C) StateFlow (or LiveData)
Explanation: StateFlow holds the latest state and emits updates.
Discuss this question
2. AsyncTask was deprecated in: Android 14 Android 8.0 Android 11 (API 30) Android 5.0 Answer: C) Android 11 (API 30)
Explanation: AsyncTask is deprecated from API 30; use coroutines or executors.
Discuss this question
3. Updating a TextView from a background thread causes: OutOfMemoryError NetworkOnMainThreadException CalledFromWrongThreadException ActivityNotFoundException Answer: C) CalledFromWrongThreadException
Explanation: Only the UI thread may touch views.
Discuss this question
4. "Structured concurrency" means: Threads are created manually All coroutines run in a fixed order Coroutines can only run once Coroutines are children of a scope, so cancelling the scope cancels them all Answer: D) Coroutines are children of a scope, so cancelling the scope cancels them all
Explanation: It prevents leaked coroutines.
Discuss this question
5. Which class is deprecated and replaced by WorkManager or JobIntentService alternatives? IntentService Activity Service Fragment Answer: A) IntentService
Explanation: IntentService is deprecated from API 30.
Discuss this question
6. Which method runs code on the UI thread from a background thread inside an activity? runInBackground Thread.sleep() runOnUiThread startService() Answer: C) runOnUiThread
Explanation: runOnUiThread posts the block to the main thread.
Discuss this question
7. Which dispatcher is best for CPU-intensive work like sorting a huge list? Dispatchers.Default Dispatchers.IO Dispatchers.Main Dispatchers.UI Answer: A) Dispatchers.Default
Explanation: Default uses a pool sized to CPU cores.
Discuss this question
8. Coroutines started in viewModelScope are cancelled when: The user scrolls The screen rotates The phone sleeps The ViewModel is cleared Answer: D) The ViewModel is cleared
Explanation: viewModelScope survives rotation and is cancelled in onCleared.
Discuss this question
9. Which is NOT a task to move off the main thread? Setting a TextView's text to a short string Decoding a large image Downloading a file Querying a large database Answer: A) Setting a TextView's text to a short string
Explanation: Short UI updates belong on the main thread.
Discuss this question
10. Music playback that continues with an ongoing notification should use a: Toast WorkManager job BroadcastReceiver Foreground service Answer: D) Foreground service
Explanation: Foreground services perform user-noticeable ongoing work.
Discuss this question
11. With Play App Signing, Google holds the: Debug keystore Source code App signing key, while the developer uses an upload key Developer's password Answer: C) App signing key, while the developer uses an upload key
Explanation: Google re-signs delivered APKs with the app signing key.
Discuss this question
12. The file that stores your release signing key is called a: Keystore (.jks) Gradle wrapper Bundle Manifest Answer: A) Keystore (.jks)
Explanation: The keystore holds the private key and certificate.
Discuss this question
13. R8 in release builds is used to: Sign the APK Create the keystore Shrink, optimise and obfuscate code and remove unused resources Upload to Play Answer: C) Shrink, optimise and obfuscate code and remove unused resources
Explanation: R8 replaces ProGuard for shrinking and obfuscation.
Discuss this question
14. The applicationId of a published app: Can be changed with every update Is the app's display name Must stay the same forever; changing it creates a different app Is optional Answer: C) Must stay the same forever; changing it creates a different app
Explanation: Play identifies apps by their application ID.
Discuss this question
15. A coroutine is best described as: A layout A lightweight, suspendable computation that does not block threads A database table A heavy operating-system thread Answer: B) A lightweight, suspendable computation that does not block threads
Explanation: Coroutines suspend instead of blocking, so many can run on few threads.
Discuss this question
16. WorkManager constraints can require that work runs only when: The device has a network connection or is charging The app is in landscape The screen is rotated A Toast is shown Answer: A) The device has a network connection or is charging
Explanation: Constraints include network type, charging, battery not low, storage not low.
Discuss this question
17. Which value must increase with every new version uploaded to Google Play? versionName applicationId versionCode minSdk Answer: C) versionCode
Explanation: versionCode is an integer compared by Play to identify newer builds.
Discuss this question
18. An ANR dialog appears when the main thread does not respond to input for about: 1 second 2 minutes 5 seconds 30 seconds Answer: C) 5 seconds
Explanation: Input dispatch timeout is about 5 seconds.
Discuss this question
19. Which Jetpack library is recommended for deferrable work that must run even after the app closes or the device restarts? WorkManager Navigation Room AppCompat Answer: A) WorkManager
Explanation: WorkManager guarantees execution under constraints.
Discuss this question
20. Two threads waiting for each other forever is called: ANR Fragmentation Race condition Deadlock Answer: D) Deadlock
Explanation: Deadlock blocks both threads permanently.
Discuss this question
21. The minimum interval of a periodic WorkManager request is: 1 hour 15 minutes 1 minute 1 day Answer: B) 15 minutes
Explanation: PeriodicWorkRequest has a 15-minute minimum.
Discuss this question
22. A Looper's job is to: Compile code Run a loop that takes messages from the MessageQueue and dispatches them Connect to Wi-Fi Loop animations Answer: B) Run a loop that takes messages from the MessageQueue and dispatches them
Explanation: Each Looper processes its thread's message queue.
Discuss this question
23. New apps on Google Play must be published as: ZIP files Android App Bundles (AAB) APK files only IPA files Answer: B) Android App Bundles (AAB)
Explanation: AAB is mandatory for new apps since August 2021.
Discuss this question
24. Which builder returns a result that can be awaited? post launch runOnUiThread async Answer: D) async
Explanation: async returns a Deferred whose result is obtained with await().
Discuss this question
25. A Handler is used to: Store preferences Post messages or runnables to a thread's message queue (e.g. delayed tasks) Draw layouts Sign APKs Answer: B) Post messages or runnables to a thread's message queue (e.g. delayed tasks)
Explanation: Handlers work with Loopers and MessageQueues.
Discuss this question
Page 1 of 2 Next
Practise Threading and Publishing Android Applications MCQs
More Computer Science chapters