programming
beginner
10 sample questions
Android Development MCQ Practice Test
Writing Java/Kotlin code using Android Studio.
Managing layouts with XML or LinearLayouts.
Q1. Android Jetpack, announced by Google in 2018, is best described as which of the following?
-
A. A suite of libraries and developer tools that work across Android versions and are largely backward-compatible ✓
-
B. A new version of the Android operating system
-
C. A programming language for Android apps
-
D. A hardware certification program for Android devices
Explanation: Jetpack is a collection of Android libraries, tools and guidance (androidx packages such as LiveData, ViewModel, Room and Navigation) designed to work across Android versions, including older API levels. It is not tied to any single API level, and it is neither an OS release nor a language.
Q2. In Android and Java development, what does holding an object through a java.lang.ref.WeakReference accomplish?
-
A. The object can still be garbage-collected when no strong references to it remain ✓
-
B. The object is permanently protected from garbage collection
-
C. The object becomes usable only from the main thread
-
D. The object's state is automatically saved across configuration changes
Explanation: A WeakReference exerts no strong claim on its target: once the last strong reference disappears, the garbage collector may collect the object and the weak reference is cleared. Android developers use this pattern (for example holding an Activity or View from a background task) precisely to AVOID memory leaks. There is no standard 'retain annotation' associated with WeakReference.
Q3. In an Android project using the Gradle Kotlin DSL (build.gradle.kts), which is the recommended way to apply the Android Gradle Plugin?
-
A. plugins { id("com.android.application") } ✓
-
B. applyPlugin('com.android.application')
-
C. use plugin: "com.android.application"
-
D. import com.android.application
Explanation: The Kotlin DSL recommends the plugins { } block, which is type-safe and applies plugins in a controlled order. "applyPlugin(" is not a real Gradle method - the Groovy DSL uses "apply plugin:" and legacy scripts use apply().
Q4. In Android development, what is the purpose of the ConstraintSet class when working with ConstraintLayout?
-
A. To capture a set of constraints and apply them later, enabling transitions between layout states ✓
-
B. To inspect the view hierarchy for performance debugging
-
C. To measure and resize views when the device rotates
-
D. To declare layout margins in XML
Explanation: ConstraintSet stores the constraints of a ConstraintLayout and can be applied programmatically — typically to animate or switch between two layout configurations. View inspection is done with the Layout Inspector tool; margins are set with layout_margin attributes.
Q5. What is the purpose of the "\/\/" (//) comment style in Android development?
-
A. It is used to disable a method or block of code for debugging purposes.
-
B. It is used to indicate a TODO or FIXME comment for future reference. ✓
-
C. It is used to indicate a comment that will be removed before release.
-
D. It is used to indicate a comment that will be executed at runtime.
Explanation: In Android development, the "//" comment style is used to indicate a TODO or FIXME comment for future reference. This style of comment is typically used to remind developers of tasks that need to be completed or issues that need to be addressed in the code.
Q6. What is the purpose of the 'android:exported' attribute in the AndroidManifest.xml file when declaring a service?
-
A. To specify the intent filters for the service
-
B. To restrict the service from being exported to other applications ✓
-
C. To specify the process in which the service will run
-
D. To enable the service to receive broadcast intents
Explanation: The 'android:exported' attribute is used to specify whether the service can be accessed from outside the application or not. If set to 'false', the service will not be exported and can only be accessed within the application.
Q7. What is the purpose of the "android:exported" attribute in the AndroidManifest.xml file when declaring a broadcast receiver?
-
A. To specify the component that can receive the broadcast
-
B. To specify the component that can send the broadcast
-
C. To control whether the broadcast receiver can be launched from outside the application ✓
-
D. To specify the intent filter for the broadcast receiver
Explanation: The "android:exported" attribute is used to control whether a broadcast receiver can be launched from outside the application. If set to "true", the receiver can be launched from outside the application, while if set to "false", it can only be launched from within the application.
Q8. What is the purpose of the 'android:exported' attribute in the AndroidManifest.xml file when declaring an Activity?
-
A. To specify the package name of the Activity
-
B. To declare the Activity as a service
-
C. To control whether the Activity can be launched from outside the application ✓
-
D. To specify the icon of the Activity
Explanation: The 'android:exported' attribute is used to control whether an Activity can be launched from outside the application. If set to 'true', the Activity can be launched from other applications, while if set to 'false', it can only be launched from within the same application.
Q9. What is the purpose of the \u0022android:exported\u0022 attribute in the AndroidManifest.xml file when declaring an activity or service?
-
A. To specify the component's intent filters
-
B. To declare the component as accessible from other applications ✓
-
C. To prevent the component from being launched by the user
-
D. To specify the component's icon
Explanation: The \u0022android:exported\u0022 attribute determines whether a component can be accessed from outside the application. If set to \u0022true\u0022, the component can be launched by other applications; if set to \u0022false\u0022, it can only be launched by the application itself.
Q10. In Android, what is the purpose of the 'onTrimMemory' method in the 'Application' class?
-
A. To handle low memory conditions ✓
-
B. To manage app data storage
-
C. To optimize app performance
-
D. To handle app lifecycle events
Explanation: The 'onTrimMemory' method is called when the system runs low on memory, and it provides a way for the app to release memory and resources to prevent being terminated. This method is typically implemented in the 'Application' class to handle low memory conditions.
That was just a sample. Sign up to unlock the full question bank with timed tests and certificates.
Sign Up Free