Android MCQ Quiz Post category:ANDROID STUDIO QUIZE Post comments:0 Comments Reading time:1 mins read Android Multiple Choice Questions and Answers Welcome to the Android Multiple Choice Questions and Answers quiz! This quiz is designed to help you test and enhance your knowledge of Android development. Whether you’re a beginner looking to learn the basics or an experienced developer aiming to refine your skills, this quiz offers a comprehensive range of questions to challenge you. 1 / 25 What is the purpose of the onUpgrade() method in SQLiteOpenHelper? To handle database creation To manage network connections To handle database version changes and migrations To perform UI updates The `onUpgrade()` method in `SQLiteOpenHelper` is called when the database needs to be upgraded. This typically occurs when the database version is incremented. The method is used to handle schema changes and data migrations. 2 / 25 Which of the following is a valid use of the intent-filter element in the Android manifest? To define an activity's layout To specify the permissions required by the app To declare the types of intents an activity, service, or broadcast receiver can respond to To manage background tasks The intent-filter element in the Android manifest is used to declare the types of intents an activity, service, or broadcast receiver can respond to. It specifies actions, categories, and data that the component can handle. 3 / 25 Which class in Android is used to create a floating action button (FAB)? FloatingButton FloatingActionButton ActionButton FloatButton The FloatingActionButton class is used to create a floating action button (FAB) in Android. It is a circular button that floats above the UI and is used for a primary action. 4 / 25 Which annotation is used to define a Room database entity? @Database @Entity @Dao @Table 5 / 25 Which method in the Activity class is used to retrieve a reference to a view by its ID? getViewById() findViewById() findView() getView() 6 / 25 Which of the following statements about SQLiteOpenHelper is true? It manages UI updates It helps to manage database creation and version management It handles network requests It performs background tasks SQLiteOpenHelper is a helper class to manage database creation and version management. It provides methods to create, update, and manage the SQLite database. 7 / 25 What is the purpose of the ANR (Application Not Responding) dialog in Android? To notify the user that the app is crashing To inform the user that the app is not responding and offer to close it To debug network issues To report an error in the app's layout The ANR (Application Not Responding) dialog appears when the main thread of an app has been unresponsive for a significant period (typically 5 seconds for a broadcast receiver or 10 seconds for an activity). It informs the user that the app is not responding and offers the option to wait or close the app. 8 / 25 Which of the following is used to define the minimum version of Android required to run an app? targetSdkVersion minSdkVersion buildToolsVersion compileSdkVersion 9 / 25 Which method is used to retrieve data from a Cursor object in Android? getString() getValue() retrieveData() fetchData() Methods like getString(), getInt(), getFloat(), etc., are used to retrieve data from a Cursor object in Android. These methods extract the value of the specified column as the corresponding data type. 10 / 25 Which of the following attributes is used to specify the type of an Android activity in the manifest file? android:name android:label android:launchMode android:theme The android:launchMode attribute is used to specify the launch mode of an activity in the Android manifest file. It defines how the activity should be launched and what its relationship with other activities should be. 11 / 25 Which of the following classes provides a simple way to handle touch gestures in Android? GestureDetector MotionEvent View TouchHandler The GestureDetector class provides a simple way to handle touch gestures in Android. It can detect various gestures such as taps, swipes, and flings. 12 / 25 What is the main purpose of SharedPreferences in Android? To handle background tasks To perform network operations To manage database operations To store small amounts of primitive data as key-value pairs 13 / 25 Which XML attribute is used to specify the gravity of a view or layout in Android? android:layout_weight android:layout_gravity android:gravity android:layout_align The android:gravity attribute is used to specify how the content of a view should be positioned within its own bounds. android:layout_gravity is used to position the view within its parent. 14 / 25 Which Android component is used to show a scrollable list of items? ScrollView RecyclerView RecyclerView is used to show a scrollable list of items in Android. It is a more advanced and flexible version of ListView. 15 / 25 Which of the following is used to run a task on a background thread in Android? Handler AsyncTask Thread All of the above 16 / 25 Which method is used to check if a permission is granted in Android? checkPermission() requestPermission() verifyPermission() checkSelfPermission() The checkSelfPermission() method is used to check if a permission is granted in Android. It returns PackageManager.PERMISSION_GRANTED if the permission is granted, otherwise PackageManager.PERMISSION_DENIED. 17 / 25 Which method is used to display a dialog in Android? showDialog() createDialog() displayDialog() alertDialog() 18 / 25 What is the primary use of the Service component in Android? To display a list of items To perform long-running operations in the background To handle touch events To manage the app's UI A Service is a component in Android that performs long-running operations in the background. Services can run independently of an activity and can continue running even if the user switches to another app. 19 / 25 Which annotation is used to indicate that a method is deprecated in Android? @Outdated @Deprecated @Override @Removed 20 / 25 What does the Parcelable interface in Android allow you to do? Parse XML data Serialize objects so they can be passed between activities Manage background threads Handle click events The Parcelable interface in Android is used to serialize objects so they can be passed between activities and fragments. It is a more efficient alternative to Java’s Serializable interface for Android. 21 / 25 Which method is used to register a BroadcastReceiver programmatically in Android? registerReceiver() startReceiver() bindReceiver() initializeReceiver() The registerReceiver() method is used to register a BroadcastReceiver programmatically. This method takes a BroadcastReceiver object and an IntentFilter object as parameters. 22 / 25 What is the purpose of the R class in an Android project? To manage network requests To handle user interactions To reference resources in the app To define the app's navigation The R class is an automatically generated class in Android that contains resource IDs for all the resources in the app. Developers use these IDs to access resources like layouts, strings, and drawables in their code. 23 / 25 What is the purpose of the onCreateOptionsMenu() method in an Android activity? To initialize the activity To create the activity's options menu To handle user input To start a new activity The `onCreateOptionsMenu()` method is called when the activity’s options menu is being created. It is used to inflate the menu and define the menu items. 24 / 25 Which method in the Activity class is called when the activity is no longer visible to the user? onPause() onStop() onDestroy() onRestart() The `onStop()` method is called when the activity is no longer visible to the user. It may be followed by either `onRestart()` if the activity comes back to the foreground or `onDestroy()` if the activity is finished. 25 / 25 Which of the following is a recommended practice for improving performance when dealing with large lists in RecyclerView? Using GridLayout Implementing ViewHolder pattern Using ViewPager Using ListView Implementing the `ViewHolder` pattern is recommended for improving performance in `RecyclerView`. It helps to avoid frequent calls to `findViewById()` by caching the view references. Your score isThe average score is 0% 0% Restart quiz Read more articles Previous PostAndroid multiple choice Quiz You Might Also Like Android multiple choice Quiz May 18, 2024 Leave a Reply Cancel replyCommentEnter your name or username to comment Enter your email address to comment Enter your website URL (optional) Save my name, email, and website in this browser for the next time I comment.