R4RIN
Articles
Java 8
MCQS
Android MCQ Quiz Hub
Android Programming MCQ Set 4
Choose a topic to test your knowledge and improve your Android skills
1. In which situation is it acceptable to make network calls on the UI thread?
Where information is held within a dynamic view.
Network calls should always be executed on the main UI thread.
Where asynchronous data calls are required.
Network calls should never be on the main UI thread.
2. Which of the following will cause a Force Close event?
An unhandled null pointer exception.
An unhandled invalid parser exception.
Attempting a network call without the correct permissions, outside of a Try/Catch statement.
None of the above
3. Which superclass do most UI elements extend?
View
Widget
LinearLayout
Activity
4. What is a WakeLock?
A feature of the PowerManager that indicates to the system that your app requires the device to stay on.
A system-wide developer setting that prevents apps from waking up the device.
The internal name for the default Android system clock.
The internal name for the Chrome for Android password manager.
5. What is the difference between a Broadcast Receiver and an Intent Filter?
A Broadcast Receiver allows an app to register to be notified upon system or application events, an Intent Filter specifies which Intents an app can receive.
A Broadcast Receiver allows an app to receive video streams from live media sources, an Intent Filter determines which URLs are supported.
A Broadcast Receiver is a component of the TelephonyManager that determines the cellular network that the device can connect to, an Intent Filter removes noise from telephone call audio.
A Broadcast Receiver is a server-side endpoint that an app can communicate with, an Intent Filter determines which Android IDs can access the endpoint.
6. Which of the following statements are true with regard to an AsyncTask class.
AsyncTasks are executed serially on a single background thread on all versions of Android.
AsyncTasks execute on a single thread by default from Eclair to Ice Cream Sandwich, and default to thread pool from Jellybean onwards unless programmatically forced to use a single thread. The number
AsyncTasks are executed on parallel threads in all cases, but the maximum number of concurrent instances is restricted to 8 up until KitKat.
AsyncTasks execute on a single thread by default from Cupcake to Donut, and default to a single thread from Honeycomb onwards unless forced to use a thread pool.
7. With regard to Android Wear, what is Ambient Mode?
The state which some devices launch into when an app is launched via voice.
The dimmed or reduced detail display state which some devices enter when they are not being actively interacted with by the user.
Ambient mode does not apply to Android Wear devices.
https://quizack.com/android-programming/mcq/p-with-regard-to-android-wear-what-is-ambient-mode-p#:~:text=A%20high%20power%20usage%20state%20that%20is%20a%20prerequisite%20to%20rendering%20detailed%20g
8. Which feature of the Java build process allows for Android projects with more than 65k method calls?
The Gradle build process
Multidexing Proguard/Dexguard
The Android Run
Time (ART)
9. What is the purpose of Volley?
A type-safe client for consuming RESTful APIs in Android and Java in general.
A convenience library that makes network calls easier and faster.
An Android unit testing framework.
An analytics tool that can shed light on parts of an app's UI that are used most/least.
10. If required during the build process, where should sensitive information such as API Keys, keystore passwords and VCS login details be kept when using Android Studio?
In a configuration file outside of version control, such as gradle.properties.
As a hard-coded string in committed code
In AndroidManifest.xml.
In a README.txt file in the /assets directory.
11. Which of the following FragmentTransaction methods allow the transaction to occur after the parent Activity’s state has been saved?
execute()
commitAllowingStateLoss()
commitStateless()
runOnUiThread()
12. What are the two types of Intent in Android?
Bad and Good
Implicit and Explicit
Explicit and Restricted
Implicit and System
13. What is Lint?
A static code analysis tool that checks code for bugs, optimisation opportunities, common coding errors and other patterns indicating that the code could be improved.
A runtime analysis tool that checks code for bugs, optimization opportunities, common coding errors and other patterns indicating that the code could be improved
The Android layout initializer object.
A low-level interface for accessing the raw header and body of a network communication packet.
14. In the context of Android development tools, what does DDMS stand for?
Dalvik Debug Monitor Server
Download Debugging Master System
Dalvik Drive Monitor Server
Dalvik Debug Measure Service
15. In the context of Android development tools, what does DDMS stand for?
Dalvik Debug Monitor Server
Download Debugging Master System
Dalvik Drive Monitor Server
Dalvik Debug Measure Service
16. What is Guava?
An open-source project consisting of common libraries for Java, maintained and primarily developed by Google.
A hybrid web framework used for developing cross-platform apps for Windows Phone, iOS and Android.
A library that makes it easy for developers to integrate RESTful APIs using industry-standard encryption techniques.
An OpenGL graphics library aimed specifically at Android devices.
17. Which of the following is a tool used for profiling the performance of Android apps?
Pixel Perfect
Hierarchy Viewer
Genymotion
Traceview
18. Which of the following is the correct way to request permission to allow an app feature to access the internet?
uses-feature android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:feature="android.permission.INTERNET"/>
19. How could using Guava in an Android application cause problems at build time in particular?
The libraries are not supported by the Gradle build process.
The libraries are large and can cause the compiler to exceed the 65k method limit imposed by Java 7 and below.
The libraries must be compiled separately before the build process will complete.
They are deprecated, Google no longer support them so many of the methods that they contain will not compile.
20. Within the context of Android resource definitions, what do 'sw600' and 'w800' mean?
sw600 resources are referenced when the screen width exceeds 600dp in width, w800 resources are referenced when the screen width is exactly 800dp.
sw600 resources are referenced when software rendering is enabled, w800 resources are referenced when WiFi is enabled.
sw600 resources are referenced when the versionCode is 600 and the device is of small form factor, w800 resources are referenced when the versionCode is 800 and the device is of wide form factor.
sw600 resources are referenced when the screen width is smaller than 600dp in width, w800 resources are referenced when the screen width is greater than 800dp.
21. Which of the following is true when an Android device is rotated?
The Activity is destroyed and recreated.
The Activity is paused and resumed.
The Activity remains active, and the LayoutParams of its contents are provided with an alternative dimensions and values for the new orientation.
The Activity remains active, and the width of the Window is altered to match the new width of the display.
22. What is the primary purpose of an Intent?
Indicates whether a process was terminated successfully or with an error.
Provides an interface which can be used by a Fragment interact with its parent Activity.
Used in order to launch an Activity.
Used in order to send a command or data to another Application.
23. What is an Intent Filter?
Provides the OS with the data types that an application can receive from an Intent triggered elsewhere.
Filters the media types shown in an instance of the MediaStore.
Filters a defined string and removes characters of the supplied type.
Provides the OS with a list of users allowed to share content from an app.
24. What is the purpose of a Loader?
Loaders are special-case data streams that provide a bytewise iterator when accessing files from external storage.
Loaders are convenience classes that make the asynchronous fetching and loading of data into a Fragment or Activity easier.
Loaders are Android native classes that are used when graphics are drawn to screen via a canvas
Loaders are UI elements that indicate to the user at an asynchronous action is in progress
25. Which of the following enables you to use Java 8 features when building apps for Android?
retrofit
lint
retrolambda
spoon
26. What is Robotium?
An Android unit testing framework.
An Android test automation framework.
An Android graphics library.
An Android build configuration tool.
27. Which exception is thrown when an image exceeds the maximum allocated size in memory?
InvalidStateException
UnhandledException
NullPointerException
OutOfMemoryException
28. What is the purpose of the Systrace tool?
It analyzes the execution of an application and places operations into a system-wide context on a common, visual timeline.
It outlines the bounds of visual elements of an app to better identify overdraw.
both (a) and (b)
None of These
29. With regard to graphics, what is the “dirty rect”?
An object that is passed as an argument to the invalidate() method to denote the portion of screen that should be redrawn.
An area of screen that is not illuminated on the display when in ambient mode.
both (a) and (b)
None of the above
30. What is Google Cloud Messaging?
A service that can be used to send messages to Android devices using Google's cloud platform.
A data format used for accessing Google APIs.
A command and control interface for controlling servers from within an Android application.
None of the above
31. What is Espresso?
An Android hardware performance analysis library.
An Android UI testing library and API.
The name given to a specific release version of the Android OS.
An open source, free Java implementation, upon which Android is based.
32. Which of these table element does not exists?
tfoot>
<th>
<col>
<tcol>
33. What is Robolectric?
An Android unit testing framework.
An Android test automation framework.
The name given to a specific release version of the Android OS.
An open source, free Java implementation, upon which Android is based.
34. A service has lifecycle callback methods that you can implement to __ changes in the service's state and you can perform work at the appropriate stage?
load
monitor
send
file
35. By default, ArrayAdapter creates a view for each array item by calling toString() on each item and placing the contents in?
Group
TextView
List
Layout
36. Following Android Classes will uses Design Patterns?
View Holder uses Singleton Design Pattern
Adapter uses Adapter Design Pattern
Broadcast Receiver uses Observer Design Pattern
All of the above
37. The addCategory() method places a category in an Intent object, ____ deletes a category previously added, and ____ gets the set of all categories currently in the object?
destroyCategory()
removeCategory()
setCategories()
None of these
38. Which of the following are key components under the Android application Architecture?
resource externalization
content providers
notifications
All of the above
39. What does the following code? public void launchScreen(Activity activity) { Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_HOME); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); activity.startActivity(intent); }
Open Launcher screen
Open Home screen
Open New task screen
None of These
40. Technically you can use Eclipse with versions 5 and newer. However, the latest version of Eclipse was only tested on the __ JRE ?
Java 3
Java 3.5
Java 4
Java 5
41. The setData() method specifies data only as a ____ , setType() specifies it only as a MIME type, and setDataAndType() specifies it as both a URI and a MIME type. The URI is read by getData() and the type by getType()?
URL
URI
Model
Object
42. When creating main Android App project with Android studio, how can we support localization of the Android App?
main/res/AndroidManifest.xml
main/res/layout/activity_my.xml
main/res/values/strings.xml
main/res/values/styles.xml
43. What does A() function do? private void A() { B(getActivity(), "com.app.package.here"); } public void B(Context context, String packageN) { Intent i = context.getPackageManager().getLaunchIntentForPackage(packageN); if (i == null) { i.addCategory(Intent.CATEGORY_LAUNCHER); context.startActivity(i); } else { try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + packageN))); } catch (android.content.ActivityNotFoundException anfe) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + packageN))); } } }
Load application named as “com.app.package.here” and prepare for the execution
Launch other app named as “com.app.package.here”
Creates child process named as “com.app.package.here”
parent process named as “com.app.package.here”
44. An Intent object is a bundle of information and what are the object contains?
A)Component,Category
Active,Send
Type,Extra
A and C
45. What does the following code do? Calendar cal = Calendar.getInstance(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); cal.add(Calendar.DATE, -1); return dateFormat.format(cal.getTime());
Get yesterday date and returns its formatted string
Get today date and returns its formatted string
Get tomorrow date and returns its formatted string
All of the above
46. What is the output if following code executed? Values/google_maps_api.xml google_maps_key (key from https://console.developers.google.com/) AndroidManifest.xml <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" /> Build.gradle(Module: app) Dependencies{ … Compile ‘com.google.android.gms:play-services:8.4.0’ }
Load Google map API from the remote library
Get Google map key from the server and register environment variable for that
Permits geolocation service and map processing
Supports Google Map API environment for the geolocation and map related app Is This Question Helpful? like dislike ADVERTISEMENT
47. What is the output if following code executed? public int pxToDp(int px) { DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics(); int dp = Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return dp; } public int dpToPx(int dp) { DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics(); int px = Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); return px; }
pxToDp() converts pixel into screen size value, and dpToPx() works via versa
pxToDp() converts pixel into screen status value, and dpToPx() works via versa
pxToDp() converts pixel into window DPI value, and dpToPx() works via versa
https://quizack.com/android-programming/mcq/what-is-the-output-if-following-code-executed-public-int-pxtodp-int-px-displaymetrics-displaymetrics-getcontext-getresources-getdisplaymetrics-int-dp-math-r
48. After building an Android project with Android Studio, what is the purpose of generating R.java as follows? package com.intelstar.venus; public final class R { public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int app_name=0x7f040000; } }
R class is used for the linking of the resource into the source code
R class is the meta-codes for the building of the project
R class is the extension file that can be edited later for the source upgrading
R class is a meta class that the resources were built
49. If you are going to check a network connection with the below source code, what would be required to make it work? public boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); if (netInfo != null && netInfo.isConnectedOrConnecting()) return true; return false; }
android.permission.ACCESS_NETWORK_STATE
android.permission.ACCESS_NETWORK_CONNECTION
android.permission.INTERNET
android.permission.ACCESS_WIFI_STATE
50. What is the output if following code executed? final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0); for (Object object : pkgAppsList) { ResolveInfo info = (ResolveInfo) object; File file = new File(info.activityInfo.applicationInfo.publicSourceDir); // … }
Get list of installed applications and try to launch them one by one.
Get list of installed applications and get public source directory for each app
Get list of launched applications and get file handle for each app
Get list of launched applications and get public source directory for each app
51. Which of the following common design patterns are used in Android?
Model View Controller
Model View Presenter
Model View View Model
None of the above
52. Following methods called during the life cycle of an android activity are?
onStart
onStop
onDestroy
All of the above
53. Which of the following are possible states of a process?
Visible Activity
Background Activity
Empty Process
All of the above
54. Android Architecture is consisted of the following components?
Linux Kernel
Android Applications
Android Framework (Application Framework is ok)
None of these
55. Android Framework (Application Framework is ok)
Key alias:”androiddebugkey”
Keystore name:”debug.keystore
Keystore password:”android”
All of the above
56. How to show option menu using the following source on Samsung phone but cannot see it. How to fix it? try { ViewConfigurationconfig = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class .getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { e.printStackTrace(); }
startActivity(new Intent(Settings.ACTION_SETTINGS)); startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)); startActivity(new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS)); startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
It can be due to Android OS internal problem, we can try to reinstall OS and retry our work
-AndroidManifest.xml &lt;uses-permission android:name=»android.permission.ACCESS_FINE_LOCATION» /&gt; &lt;uses-permission android:name=»android.permission.ACCESS_COARSE_LOCATION» /&gt; &lt;uses-pe
None of the above
57. What does mean by the following XML code? AndroidManifest.xml <application android:label=»@string/app_name» android:icon=»@drawable/icon» android:name=»com.intel.starApp»> … …. <meta-data android:name=»DATABASE» android:value=» example.db»> <meta-data android:name=»VERSION» android:value=»2″> <meta-data android:name=»QUERY_LOG» android:value=»true»> … </meta-data></meta-data></meta-data>
Local custom DataBase file name is “example.db”, App version 2.0, Logs selected queries
Local SQLite DataBase file name is “example.db”, DBMS version 2.0, Logs selected queries
Local text-type DataBase file name is “example.db”, DBMS version 2.0, Logs selected queries
Remote DataBase file name is “example.db”, App version 2.0, Logs selected queries
58. What does the following code output? public class XYZ extends AsyncTask { @Override protected String doInBackground(String... params) { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); final WakeLockwl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK |PowerManager.ACQUIRE_CAUSES_WAKEUP |PowerManager.ON_AFTER_RELEASE, ""); wl.acquire(); return "Executed"; } @Override protected void onPostExecute(String result) {} }
Startup power manager to save screen power
unlock the screen
Wake up the phone
Lock the screen
59. Which of the following data types does AIDL support?
string
list
map
All of the above
60. The 'showAsAction' attribute of in a menu resource file can have which of the following values? Check all that apply.
ifRoom
withText
withIcon
All of the above
61. Which file contains information about the app?
android.xml
AndroidManifest.xml
Manifest.xml
strings.xml
62. Which statement correctly assigns the id to textView element in layout file?
TextView android:id=&quot;@id/textView /&gt;
&lt;TextView android:id=&quot;@+id/textView /&gt;
&lt;TextView android.id=&quot;@+id/textView /&gt;
&lt;TextView android:id=&quot;+id/textView /&gt;
63. AndroidMainfest.xml file contains the following essential information about your app: (choose all that apply)
App icon
Theme affects
App activities
All of the above
64. The strings.xml has a _________ element, which contains one or more elements.
container&gt;
&lt;main&gt;
&lt;resources&gt;
&lt;strings&gt;
65. A layout can retrieve the value of the String named 'stringmessage' using `____`.
string/string_message
#string/string_message
@string/string_message
#string_message
66. The best practice is to put string values in _________ file.
strings.xml
strings.java
android.text
resource.rsc
67. Buttons and text views both inherit from the same Android class named _____.
view.View
android.View
android.view.View
android.view.Layout
68. If the intent has extra integer information passed to it with a name of "message", we can retrieve that information using which of the following?
intent.getStringExtra(&quot;message&quot;);
intent.getIntExtra(&quot;message&quot;);
intent.getObjectExtra(&quot;message&quot;);
intent.getExtra(&quot;message&quot;);
69. Which of the following correctly adds a string array resource to strings.xml?
string_array name=”string_array_name”&gt; string_value1 string_value2 string_value3
string_value1 string_value2 string_value3
string_value1 string_value2 string_value3
None of These
70. Suppose Screen1 is the main screen of an Android application MyAndroid. Now if another screen, Screen2 has to be opened from Screen1, then which of the following are true?
Screen2 has to be a part of MyAndroid.
Screen2 can exist in any other Android application installed on the device.
Screen2 can be launched synchronously.
Screen2 can return a result code to Screen1 if launched with startActivity.
71. Which of the following can you use to display a progress bar in an Android application?
ProgressBar
requestWindowFeature
ProgressView
ProgressItem
72. One can declare a logical parent ".MainActivity" to < activity > by adding the following line in the respective < activity > in AndroidManifest.xml.
android:parentActivityName=
android:logialParentActivityName=
android:parentActivity
android:activityName=
73. Which of the following lifecycle methods are common to both Activity and Fragment?
onAttach()
onStart()
onDetach()
None of these
Submit