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?

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?

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?

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?

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?

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?

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?

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?

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?

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?

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
Android Development MCQ Practice Test | Mind Hustle