Android MCQs

Android MCQs

Try to answer these 40 Android MCQs and check your understanding of the Android subject.
Scroll down and let's begin!

1: To add features, components, and permissions to your Android app, which file needs to be edited?

A.   AndroidManifest.xml

B.   Components.xml

C.   AppManifest.xml

D.   ComponentManifest.xml

2: Which XML attribute should be used to make an Image View accessible?

A.   Android:talkBack

B.   Android:labelFor

C.   Android:hint

D.   Android:contentDescription

3: You launch your app, and when you navigate to a new screen it crashes, Which action will NOT help you diagnose the issue?

A.   Set breakpoints and then step through the code line by line

B.   Use the profiler tools in Android Studio to detect anomalies CPU, and network usage.

C.   Add a Thread.sleep() call before you start the new activity.

D.   Inspect the logs in Logcat.

4: Why might push notifications stop working?

A.   All of these answers

B.   The device token is not being sent to push provider correctly.

C.   Google Play Services is not installed on the deivce/emulator.

D.   Battery optimization is turned on on the device.

5: The Android system kills process when it needs to free up memory. The likelihood of the system killing a given process depends on the state of the process and the activity at the time. With combination of process and activity state is most likely to be killed?

A.   Process:In the background;Activity:Is stopped

B.   Process:In the background;Activity:Is paused

C.   Process:In the foreground;Activity:Is started

D.   Process:In the foreground;Activity:Is paused

6: You want to include about and setting modules in your project. Which files accurately reflects their inclusion?

A.   In build.gradle:include ':app',':about' ':settings'

B.   In settings.gradle:include ':app',':about' ':settings'

C.   In settings.gradle:include ':about',':settings'

D.   In gradle.properties:include ':app',':about' ':settings'

7: What is the benifit of using @VisibleForTesting annotation?

A.   To denote that a class, methos, or field has its visibility relaxed to make code testable

B.   To denote that a class, method, or field is visible only in the test code

C.   To denote that a class, method, or field has its visibility increased to make code less testable

D.   To throw a run-time error if a class, methos, or field with this annotation is accessed improperly

8: When will an activity's onActivityResult()be called?

A.   When calling finish()in the parent activity

B.   When placing an app into the background by sitching to another app

C.   When onStop() is called in the target activity

D.   When calling finish() in the target activity

9: You need to remove an Event based on it;s id from your API, Which code snippet defines that request in Retrofit?

A.   @DELETE("events) fun deleteEvent(@Path("id") id: Long): Call

B.   @DELETE("events/{id}") fun deleteEvent(@Path("id") id: Long): Call

C.   @REMOVE("events/{id}") fun deleteEvent(@Path("id") id: Long): Call

D.   @DELETE("events/{id}") fun deleteEvent(@Path("id") id: Long): Call

10: When would you use a product flavour in your build setup?

A.   When you need to have the app's strings present in multiple lanuages

B.   When you have to provide different versions of your app based on the physical device size

C.   When you want to provide different versions of your app based on the device screen density

D.   When you want to provide different version of your app with custom configuration and resources

11: Why do you use the AndroidJUnitRunner when running UI tests? Notice: AndroidJUnitRunner lets us run JUnit3/4-style tests on Android Devices

A.   The test runner facilitates loading your test package and the app under test onto a device or emulator, runs the test, and reports the results.

B.   The test runner creating screenshots of each screen that displayed while tests are executed.

C.   The test runner facilitates parallelization of test classes by providing for each test class.

D.   The test runner facilitates interacting with visible elements on a device, regardless of the activity or fragment that has focus.

12: What allows you to properly restore a user's state when an activity is restarted?

A.   The onSaveInstance()method

B.   All of these answers

C.   Persistent storage

D.   ViewModel objects

13: Given the definition below. how would you get access a TextView with an ID of text_home contained in thr layout file of a Fragment class?

A.   Root.find(R.id.text_home)

B.   FindViewById(R.id.text_home)

C.   Root.getById(R.id.text_home)

D.   Root.findViewById(R.id.text_home)

14: IF the main thread is blocked for too long, the system displays the _ dialog?

A.   Thread Not Responding

B.   Application Paused

C.   Application Not Responding

D.   Application Blocked

15: How would you retrieve the value of a user's email from SharedPreferences while ensuring that the returned value is not null?

A.   GetPreferances(this).getString(Email,

B.   GetDefaultSharedPrefarances(this).getString(EMAIL,null)

C.   GetDefaultSharedPreferances(this).getString(EMAIL,

D.   GetPreferances(this).getString(EMAIL,null)

16: Why is it problematic to define sizes using pixels on Android?

A.   Although screen pixel density varies, this does not impact the use of pixels to define sizes.

B.   Large devices always have more pixels, so your UI elements will be e=affected if you define them with pixels.

C.   The same number of pixels may correspond to different physical sizes, affecting the appearance of your UI elements.

D.   Different devices have different understanding of what a pixel is , affecting the appearance of your UI elements

17: You need to get a list of devices that are attached to your computer with USB debugging enable. Which command would execute using the Android Debug Bridge?

A.   List devices

B.   Adb devices

C.   List avd

D.   Dir devices

18: To persist a small collection of key-value data, what should you use?

A.   External file storage

B.   SharedPereferences

C.   SQLite

D.   Internal file storage

19: You need to retrieve a list of photos from an API. Which code snippet defines an HTML GET request in Retrofit?

A.   @GET("photo/{id}"} fun listPhotos(@Path("id") id:Long?) : Call

B.   @LIST("photo") fun listPhotos() : Call

C.   @GET("photo") fun listPhotos() : Call

D.   @GET("photo") fun listPhotos() : Call

20: Given the test class below, which code snippet would be a correct assertion?

A.   AssertThat(resultAdd).is(2.0)

B.   AssertNotNull(resultAdd)

C.   AssertThat(resultAdd).isWqualTo(2.0)

D.   AssertThat(resultAdd)

21: What tag should you use to add a reusable view component to a layout file?

A.  

B.  

C.  

D.  

22: You want to provide a different drawable for devices that are in landscape mode and whose language is set to French. which directory is named correctly?

A.   Fr-land-drawable

B.   Drawable-fr-land

C.   Drawable-french-land

D.   French-land-drawable

23: Why might you need to include the following permission to your app?

A.   Android.permission.ACCESS_NETWORK_STATE

B.   To monitor the location of the devices so that you don't attempt to make network calls when the user is stationary

C.   To request the ability to make network calls from your app

D.   To monitor the network state of the device so that you can display an in-app banner to the user

E.   To monitor the network state of the devices so that you don't attempt to make network calls when the network is unavailable

24: When should you store files in the /assets directory?

A.   When you need access to the original file names and file hierarchy

B.   When you need access to the file with its resource ID, like R.assets.filename

C.   When you have XML files that define tween animations

D.   When you need to access the file in its raw form using Resources.openRawResource()

25: You want to allow users to take pictures in your app. Which is not an advantage of creating an appropriate intent, instead of requesting the camera permission directly?

A.   Users can select their favorite photo apps to take pictures.

B.   You do not have to make a permission request in your app to take a picture.

C.   You have full control over the user experience. The app that handles the camera intent will respect your design choices.

D.   You do not have to design the UI. The app that handles the camera intent will provide the UI.

26: When would you use the ActivityCompat.shouldShowRequestPermissionRationale() function?

A.   When a user first opens your app and you want to provide an explanation for the use of a given permission

B.   When a user has previously denied the request for a given permission and selects "Tell me more"

C.   When a user has previously denied the request for a given permission and you want to provide an explanation for its use

D.   when a user has previously denied the request for a given permission and selected "Don't ask again," but you need the permission for your app to function

27: To optimize your APK size, what image codec should you use?

A.   JPG

B.   PNG

C.   MPEG

D.   WebP

28: You have built code to make a network call and tested that it works in your development environment. However, when you publish it to the Play console, the networking call fails to work. What will not help you troubleshoot this issue?

A.   Checking whether ProGuard -keepclassmembers have been added to the network data transfer objects (DTOs) in question

B.   Using the profiler tools in Android Studio to detect anomalies in CPU, memory, and network usage

C.   Checking for exceptions in the server logs or server console

D.   Checking that the network data transfer object has @SerizlizedName applied to its member properties

29: Which source set is _not_ available to you by default when Android Studio creates a new project?

A.   Test

B.   AndroidTest

C.   App

D.   Main

30: To preserve on-device memory, how might you determine that the user's device has limited storage capabilities?

A.   Use the ActivityManager.isLowRamDevice() method to find out whether a device defines itself as "low RAM."

B.   Use the Activity.islowRam() method to find out whether a device defines itself as "low RAM."

C.   Use the ConnectivityManager.hasLowMemory() method to find out whether a device defines itself as "low RAM."

D.   Make an image download request and check the remaining device storage usage.

31: What is _not_ a good way to reuse Android code?

A.   Use a common Gradle module shared by different Android projects.

B.   Prefer to build custom views or fragments over activities.

C.   Prefer to build activities instead of fragments.

D.   Break down UI layouts into common elements and use to include them in other layout XML files.

32: Which layout is best for large, complex hierarchies?

A.   LinearLayout

B.   ConstraintLayout

C.   FrameLayout

D.   RelativeLayout

33: You need to upgrade to the latest version of the Android Gradle plugin. Which file should you modify?

A.   Root_project_dir/app/build.gradle.

B.   Root_project_dir/settings.gradle.

C.   Root_project_dir/build.gradle.

D.   Root_project_dir/app/gradle.properties.

34: Why do developers often put app initialization code in the Application class?

A.   The Application class is instantiated before any other class when the process for the application is created.

B.   The Application class is instantiated after any permissions requests when the process for the application is created.

C.   The Application class is created each time a new Activity is launched, making it ideal for initialization code.

D.   The Application class is created each time a background service is called, making it ideal for initialization code.

35: What folder should you use for your app's launcher icons?

A.   /drawable

B.   /icon

C.   /mipmap

D.   /launcher

36: When should you use the androidTest directory to store your test classes?

A.   When the tests consist only of unit tests.

B.   When the number of tests to run is large(500+).

C.   When the tests need to run on your local machine.

D.   When the tests need to run on real or virtual devices.

37: Given an APK named app-internal-debug.apk produced from the build process, which statement is likely to be true?

A.   This APK is created on a developer machine from the debug product flavor.

B.   This APK is created from the internalDebug product flavor.

C.   This APK created from the debug product flavor and internal build type.

D.   This APK is created from the debug build type and internal product flavor.

38: When attempting to build your project, what might the following error indicate? Conversion to Dalvik format filed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

A.   You have included incorect format information in your build.gradle file.

B.   You have added more than 20 dependencies to your build.gradle.

C.   You have exceeded the total number of methods that can be referenced within a single DEX file.

D.   You have a NullPointerException in your code.

39: Which statement, in build.gradle file, correctly denotes that the corresponding module is an Android library module?

A.   Apply plugin: 'com.module.library'

B.   Apply plugin: 'com.android.library'

C.   Apply plugin: 'com.module.library'

D.   Include plugin: 'com.module.library'

40: What is not a benefit of externalizing app resources such as image and string from a code?

A.   It allows Android to choose the appropriate resource based on the current configuration during runtime.

B.   It allows you to have more performant applications because the code and resources are separated.

C.   It allows you to provide a different Ul experience based on the user's language settings.

D.   It allows you to provide a different Ul experience based on the user's device size.

41: Which component is not an entry point through which the system or a user can enter your app?

A.   Activity

B.   Content provider

C.   Fragment

D.   Service

42: What should you use to display a large, scrolling list of elements?

A.   ListView

B.   Recycler View

C.   LinearLayout

D.   Scrollview

43: You have created an AboutActivity class that displays details about your app. Which code snippet allows you to launch your activity?

A.   Intent(this, AboutActivity::class).also { intent -> startService(intent) }

B.   Intent(this, AboutActivity::class.java).also { intent -> startActivity(intent) }

C.   Intent(this, AboutActivity::class).also { intent -> activity(intent) }

D.   Intent(this, AboutActivity::class).also { intent -> startActivity(intent) } Explanation: Intent(Context packageContext, Class cls) Notice: Class not KClass

44: What is the use of AndroidManifest.xml file?

A.   It describes the component of the application

B.   It declares the minimum level of the android API that the application requires

C.   It facilitates to provide a uinque name for the application by specifying package name

D.   All of the above

45: Which attribute of the element is used to specify the minimum API Level required for the application to run?

A.   Android:targetSdkVersion

B.   Android:minSdkVersion

C.   Android:maxSdkVersion

D.   None of the above

46: To shrink your code in release builds, what tool does Android Studio use?

A.   R8

B.   ProGuard

C.   Shrinker

D.   D8 Explanation: When you build your project using Android Gradle plugin 3.4.0 or higher, the plugin no longer uses ProGuard to perform compile-time code optimization. Instead, the plugin works with the R8 compiler to handle

A.   WorkManager

B.   AsyncTask

C.   IntentService

D.   Thread

48: You need to provide your users with certain features of your app on-demand or as instant experiences through Google Play. Which type of module should you create?

A.   Library module

B.   Dynamic feature module

C.   Android app module

D.   Google Cloud module

49: If you need your app code to inspect information about the current build, which class should you use?

A.   BuildConfig

B.   BuildInfo

C.   ConfigParams

D.   ConfigInfo