






































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Covers entry-level Android development competencies including Android Studio, project structure, activities, fragments, layouts, UI components, intents, application lifecycle, and build processes. Also assesses understanding of Java/Kotlin fundamentals, debugging, resource management, and packaging applications.
Typology: Exams
1 / 78
This page cannot be seen from the preview
Don't miss anything!







































































Question 1. Which Kotlin keyword is used to declare an immutable reference? A) var B) val C) const D) let Answer: B Explanation: val creates a read-only reference; its value cannot be reassigned after initialization, unlike var. Question 2. In Kotlin, what does the Elvis operator (?:) return when the left-hand expression is null? A) Throws a NullPointerException B) The right-hand expression C) The left-hand expression unchanged D) An empty string Answer: B Explanation: The Elvis operator provides a default value; if the left side is null, the right side is returned. Question 3. Which of the following is a correct way to call a function with named arguments in Kotlin? A) foo(1, 2) B) foo(a = 1, b = 2) C) foo[1,2] D) foo{a:1, b:2} Answer: B Explanation: Kotlin allows named arguments using the syntax parameterName = value.
Question 4. In Java, which access modifier makes a member visible only within its own package and subclasses? A) private B) protected C) public D) default (package-private) Answer: B Explanation: protected grants visibility to the same package and to subclasses even if they are in different packages. Question 5. Which Android component is responsible for handling long-running background tasks without a UI? A) Activity B) Service C) BroadcastReceiver D) ContentProvider Answer: B Explanation: A Service runs in the background and can continue even when the user is not interacting with the app. Question 6. What is the primary purpose of the AndroidManifest.xml file? A) Store UI layout definitions B) Declare app components, permissions, and metadata C) List all Gradle dependencies D) Define Kotlin data classes Answer: B Explanation: The manifest registers activities, services, receivers, providers, required permissions, and other app metadata. Question 7. Which lifecycle method is always called after onStart() when an activity becomes visible and ready for user interaction?
C) setAction() D) setData() Answer: A Explanation: putExtra() attaches key-value pairs (e.g., int, String) to the Intent for retrieval in the target activity. Question 11. Which layout is most suitable for creating a responsive UI that aligns views relative to each other without nested hierarchies? A) LinearLayout B) FrameLayout C) ConstraintLayout D) TableLayout Answer: C Explanation: ConstraintLayout lets you define constraints between views, reducing nesting and improving performance. Question 12. In Android resources, which qualifier is used to provide alternative layouts for portrait orientation? A) -land B) -port C) -v D) -sw600dp Answer: B Explanation: The -port qualifier selects resources when the device is in portrait orientation. Question 13. Which XML attribute defines a view’s width to match the parent’s width? A) android:layout_height="wrap_content" B) android:layout_width="match_parent" C) android:layout_width="fill_parent" (deprecated)
D) Both B and C are valid Answer: D Explanation: match_parent is the modern term; fill_parent works but is deprecated. Question 14. Which of the following UI widgets is best suited for displaying a scrollable list of heterogeneous items? A) ListView B) RecyclerView C) GridView D) ScrollView Answer: B Explanation: RecyclerView efficiently recycles item views and supports multiple view types. Question 15. What method must be overridden in a RecyclerView.Adapter to create a new ViewHolder? A) onCreateViewHolder() B) onBindViewHolder() C) getItemCount() D) getItemViewType() Answer: A Explanation: onCreateViewHolder() inflates the item layout and returns a new ViewHolder instance. Question 16. Which Gradle keyword is used to add a library dependency to an Android module? A) implementation B) compileOnly C) runtimeOnly D) provided Answer: A
Question 20. What is the default threading model for Android UI components? A) Background thread B) Main (UI) thread C) Worker thread pool D) IO thread Answer: B Explanation: All UI updates must occur on the main thread; performing long work there causes ANR. Question 21. Which Android Jetpack component helps you navigate between destinations while handling back stack automatically? A) LiveData B) Navigation Component C) WorkManager D) DataBinding Answer: B Explanation: The Navigation Component provides NavHost, NavController, and safe-args for declarative navigation. Question 22. Which method of SharedPreferences is used to write changes atomically? A) apply() B) commit() C) edit() D) putString() Answer: B Explanation: commit() writes synchronously and returns a boolean indicating success; apply() writes asynchronously.
Question 23. In Room persistence library, which annotation defines a DAO interface? A) @Entity B) @Dao C) @Database D) @Query Answer: B Explanation: @Dao marks an interface or abstract class that contains methods for database operations. Question 24. Which SQL statement is used to retrieve all columns from a table named "User"? A) SELECT * FROM User; B) GET ALL FROM User; C) FETCH * FROM User; D) RETRIEVE * FROM User; Answer: A Explanation: SELECT * FROM User; is the standard SQL query to fetch all rows and columns. Question 25. Which Android permission is required to write files to external storage on Android 10 and lower? A) READ_EXTERNAL_STORAGE B) WRITE_EXTERNAL_STORAGE C) MANAGE_EXTERNAL_STORAGE D) ACCESS_MEDIA_LOCATION Answer: B Explanation: WRITE_EXTERNAL_STORAGE grants write access to external storage; from Android 11 onward, scoped storage changes apply. Question 26. Which lifecycle callback is invoked when a bound Service is first created?
D) class User(data val id: Int, data var name: String) Answer: A Explanation: Data classes must be prefixed with data and properties are declared in the primary constructor; using val/var is required. Question 30. Which Android UI component is most appropriate for displaying a set of mutually exclusive options? A) CheckBox B) RadioButton within RadioGroup C) Switch D) ToggleButton Answer: B Explanation: RadioButtons inside a RadioGroup enforce a single selection among the group. Question 31. Which Gradle plugin is applied to enable Kotlin Android support? A) com.android.application B) org.jetbrains.kotlin.android C) kotlin-android D) android-kotlin-plugin Answer: C Explanation: kotlin-android plugin adds Kotlin compilation to an Android module. Question 32. Which method of the Fragment class is called when the fragment’s UI is first created? A) onCreate() B) onCreateView() C) onViewCreated() D) onActivityCreated() Answer: B Explanation: onCreateView() inflates and returns the fragment’s view hierarchy.
Question 33. In Android, which component is designed to receive broadcast messages from the system or other apps? A) Service B) Activity C) BroadcastReceiver D) ContentProvider Answer: C Explanation: BroadcastReceiver handles asynchronous broadcast intents. Question 34. Which annotation is used to indicate that a Kotlin function should be executed on the main thread when using Coroutines? A) @MainThread B) @UiThread C) @Dispatcher(Main) D) withContext(Dispatchers.Main) Answer: D Explanation: withContext(Dispatchers.Main) switches coroutine execution to the main thread; there is no direct annotation for this purpose. Question 35. Which Android API level introduced the Permission model that requires runtime user consent? A) API 15 B) API 16 C) API 21 D) API 23 Answer: D Explanation: Android 6.0 (API 23) introduced runtime permissions. Question 36. Which of the following statements about the Android Application class is true?
B) @POST("users") fun getUsers(): Call> C) @GET("users") fun getUsers(): List D) @GET("users") fun getUsers(): Response Answer: A Explanation: Using @GET with suspend returns the parsed list directly when using Retrofit’s Kotlin coroutine support. **Question 40. Which Android resource type should be used for storing color values? ** A) /values/colors.xml B) /drawable/color.xml C) /layout/colors.xml D) /raw/colors.xml Answer: A Explanation: Color resources are defined in a values XML file named colors.xml. Question 41. What is the primary advantage of using a Set over a List in Kotlin collections? A) Allows duplicate elements B) Maintains insertion order C) Guarantees uniqueness of elements D) Provides indexed access Answer: C Explanation: A Set enforces that each element appears only once. Question 42. Which method of the Context class is used to retrieve a system service like LayoutInflater? A) getSystemService(Class) B) getService(String) C) getSystemService(String) D) obtainService(Class)
Answer: C Explanation: getSystemService(String name) returns the requested system service; the newer generic version exists but the classic method uses a name constant. Question 43. In Android, which file defines the navigation graph when using the Navigation Component? A) nav_graph.xml in res/navigation/ B) navigation.xml in res/layout/ C) nav_graph.json in assets/ D) navigation_graph.xml in res/xml/ Answer: A Explanation: Navigation graphs are stored as XML resources under res/navigation/. Question 44. Which annotation is used to indicate that a field in a Room @Entity should be the primary key? A) @PrimaryKey B) @Key C) @Id D) @Unique Answer: A Explanation: @PrimaryKey marks the column that uniquely identifies a row. Question 45. Which method in a ContentProvider is used to insert a new row into the underlying data store? A) query() B) insert() C) update() D) delete() Answer: B
Question 49. Which Android class is used to display a modal dialog with a list of selectable items? A) AlertDialog B) DialogFragment C) PopupWindow D) Snackbar Answer: A Explanation: AlertDialog can show a list via setItems() or setSingleChoiceItems(). Question 50. What does the android:launchMode="singleTop" attribute affect? A) The way intents are filtered. B) The number of activity instances in the back stack. C) The animation used when launching the activity. D) Whether the activity can be launched from the home screen. Answer: B Explanation: singleTop reuses the existing instance if it is already at the top of the task’s back stack. Question 51. Which of the following is NOT a valid way to start a coroutine in Android? A) launch { … } in a LifecycleScope B) async { … } in GlobalScope C) runBlocking { … } on the UI thread D) startActivity { … } Answer: D Explanation: startActivity is an Android method, not a coroutine builder. Question 52. Which method of View is used to set a click listener in Kotlin using a lambda expression?
A) setOnClickListener { … } B) onClick { … } C) click { … } D) addClickListener { … } Answer: A Explanation: setOnClickListener accepts a lambda that implements View.OnClickListener. Question 53. In the Android Gradle build system, which file contains the SDK version declarations? A) settings.gradle B) build.gradle (module level) C) gradle.properties D) AndroidManifest.xml Answer: B Explanation: compileSdkVersion, minSdkVersion, and targetSdkVersion are defined in the module-level build.gradle. Question 54. Which Kotlin collection type preserves insertion order and allows duplicate elements? A) Set B) List C) Map D) Sequence Answer: B Explanation: List maintains order and can contain duplicates. Question 55. Which method is used to register a BroadcastReceiver dynamically at runtime? A) registerReceiver() B) addReceiver()
Explanation: WorkManager handles deferrable, guaranteed background tasks and can reschedule after reboot. Question 59. Which method of Activity is called when the activity becomes partially obscured but still visible (e.g., when a dialog appears)? A) onPause() B) onStop() C) onResume() D) onStart() Answer: A Explanation: onPause() is invoked when the activity loses focus but remains visible. Question 60. In Android, which layout attribute is used to align a view to the start of its parent in a ConstraintLayout? A) app:layout_constraintStart_toStartOf="parent" B) android:layout_alignParentStart="true" C) app:layout_constraintLeft_toLeftOf="parent" D) android:layout_marginStart="0dp" Answer: A Explanation: In ConstraintLayout, layout_constraintStart_toStartOf defines a start-to-start constraint relative to the parent. Question 61. Which of the following statements about LiveData is true? A) It can be observed only from background threads. B) It automatically stops updates when the observer’s lifecycle is DESTROYED. C) It holds a mutable reference that cannot be changed. D) It requires manual removal of observers to avoid memory leaks. Answer: B Explanation: LiveData respects the lifecycle of its observers and stops sending updates after DESTROYED.
Question 62. Which Android API is used to parse JSON into Kotlin data classes with minimal boilerplate? A) org.json.JSONObject B) Gson C) Moshi D) Kotlinx Serialization (with Json) Answer: D Explanation: Kotlinx Serialization provides a compile-time JSON parser that works seamlessly with Kotlin data classes. Question 63. Which method of ActivityResultLauncher is used to launch an intent for a result in the new Activity Result API? A) launch() B) startActivityForResult() C) request() D) execute() Answer: A Explanation: ActivityResultLauncher.launch(intent) starts the activity and handles the callback. Question 64. Which Android view group is optimized for stacking child views on top of each other? A) LinearLayout B) FrameLayout C) GridLayout D) TableLayout Answer: B Explanation: FrameLayout places children relative to the top-left corner, allowing overlap. Question 65. Which of the following is a correct way to declare a Kotlin enum class with values RED, GREEN, BLUE?