programming
beginner
10 sample questions
Android Development MCQ Practice Test
Writing Java/Kotlin code using Android Studio.
Managing layouts with XML or LinearLayouts.
Q1. Which Android API level introduced the concept of 'Jetpack', a set of libraries and tools that help developers build robust, high-quality apps?
-
A. API Level 16
-
B. API Level 21
-
C. API Level 24
-
D. API Level 27
Explanation: Android API level 21 introduced the concept of Jetpack, which includes libraries and tools such as LiveData, ViewModel, and Room persistence library.
Q2. What is the purpose of the \u0022retain\u0022 annotation in Android when used with a \u0022WeakReference\u0022?
-
A. To indicate that the object should be garbage collected immediately
-
B. To prevent the object from being garbage collected ✓
-
C. To specify the reference type of the object
-
D. To enable the object to be accessed from multiple threads
Explanation: The \u0022retain\u0022 annotation is used to prevent the object from being garbage collected when used with a \u0022WeakReference\u0022. This is useful in scenarios where the object needs to be kept alive for a longer period.
Q3. What is the purpose of the 'applyPlugin(' method in the 'build.gradle' file of an Android project, when using the Kotlin DSL?
-
A. 'applyPlugin(' is used to enable the Android Gradle Plugin's Java-based DSL.
-
B. 'applyPlugin(' is used to enable the Android Gradle Plugin's Kotlin-based DSL. ✓
-
C. 'applyPlugin(' is used to enable the Android Gradle Plugin's incremental build feature.
-
D. 'applyPlugin(' is used to enable the Android Gradle Plugin's multi-module build feature.
Explanation: The 'applyPlugin(' method in the 'build.gradle' file is used to enable the Android Gradle Plugin's Kotlin-based DSL when using the Kotlin DSL. This allows developers to write their build logic in Kotlin, making it easier to manage complex build configurations.
Q4. In Android, what is the purpose of the !@[] annotation in a layout file when using the ConstraintLayout?
-
A. To specify a custom layout inspector
-
B. To enable layout resizing
-
C. To define a constraint set ✓
-
D. To specify a layout margin
Explanation: The !@[] annotation is used to define a constraint set in a layout file when using the ConstraintLayout. This allows developers to define a set of constraints that can be applied to multiple views in the layout, making it easier to manage complex layouts.
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