Android MCQ Quiz Hub

Android Programming MCQ Set 4

Choose a topic to test your knowledge and improve your Android skills

In which situation is it acceptable to make network calls on the UI thread?





✅ Correct Answer: 3

Which of the following will cause a Force Close event?





✅ Correct Answer: 1

Which superclass do most UI elements extend?





✅ Correct Answer: 1

What is a WakeLock?





✅ Correct Answer: 1

What is the difference between a Broadcast Receiver and an Intent Filter?





✅ Correct Answer: 1

Which of the following statements are true with regard to an AsyncTask class.





✅ Correct Answer: 1

With regard to Android Wear, what is Ambient Mode?





✅ Correct Answer: 2

Which feature of the Java build process allows for Android projects with more than 65k method calls?





✅ Correct Answer: 2

What is the purpose of Volley?





✅ Correct Answer: 2

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?





✅ Correct Answer: 1

Which of the following FragmentTransaction methods allow the transaction to occur after the parent Activity’s state has been saved?





✅ Correct Answer: 2

What are the two types of Intent in Android?





✅ Correct Answer: 2

What is Lint?





✅ Correct Answer: 1

In the context of Android development tools, what does DDMS stand for?





✅ Correct Answer: 1

In the context of Android development tools, what does DDMS stand for?





✅ Correct Answer: 1

What is Guava?





✅ Correct Answer: 1

Which of the following is a tool used for profiling the performance of Android apps?





✅ Correct Answer: 4

Which of the following is the correct way to request permission to allow an app feature to access the internet?





✅ Correct Answer: 3

How could using Guava in an Android application cause problems at build time in particular?





✅ Correct Answer: 2

Within the context of Android resource definitions, what do 'sw600' and 'w800' mean?





✅ Correct Answer: 1

Which of the following is true when an Android device is rotated?





✅ Correct Answer: 1

What is the primary purpose of an Intent?





✅ Correct Answer: 4

What is an Intent Filter?





✅ Correct Answer: 1

What is the purpose of a Loader?





✅ Correct Answer: 2

Which of the following enables you to use Java 8 features when building apps for Android?





✅ Correct Answer: 3

What is Robotium?





✅ Correct Answer: 2

Which exception is thrown when an image exceeds the maximum allocated size in memory?





✅ Correct Answer: 4

What is the purpose of the Systrace tool?





✅ Correct Answer: 1

With regard to graphics, what is the “dirty rect”?





✅ Correct Answer: 1

What is Google Cloud Messaging?





✅ Correct Answer: 1

What is Espresso?





✅ Correct Answer: 2

Which of these table element does not exists?





✅ Correct Answer: 1

What is Robolectric?





✅ Correct Answer: 1

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?





✅ Correct Answer: 2

By default, ArrayAdapter creates a view for each array item by calling toString() on each item and placing the contents in?





✅ Correct Answer: 2

Following Android Classes will uses Design Patterns?





✅ Correct Answer: 4

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?





✅ Correct Answer: 2

Which of the following are key components under the Android application Architecture?





✅ Correct Answer: 4

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); }





✅ Correct Answer: 2

Technically you can use Eclipse with versions 5 and newer. However, the latest version of Eclipse was only tested on the __ JRE ?





✅ Correct Answer: 4

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()?





✅ Correct Answer: 2

When creating main Android App project with Android studio, how can we support localization of the Android App?





✅ Correct Answer: 3

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))); } } }





✅ Correct Answer: 2

An Intent object is a bundle of information and what are the object contains?





✅ Correct Answer: 4

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());





✅ Correct Answer: 1

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’ }





✅ Correct Answer: 1

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; }





✅ Correct Answer: 1

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; } }





✅ Correct Answer: 1

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; }





✅ Correct Answer: 1

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); // … }





✅ Correct Answer: 2

Which of the following common design patterns are used in Android?





✅ Correct Answer: 1

Following methods called during the life cycle of an android activity are?





✅ Correct Answer: 4

Which of the following are possible states of a process?





✅ Correct Answer: 4

Android Architecture is consisted of the following components?





✅ Correct Answer: 1

Android Framework (Application Framework is ok)





✅ Correct Answer: 4

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(); }





✅ Correct Answer: 4

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>





✅ Correct Answer: 2

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) {} }





✅ Correct Answer: 4

Which of the following data types does AIDL support?





✅ Correct Answer: 4

The 'showAsAction' attribute of in a menu resource file can have which of the following values? Check all that apply.





✅ Correct Answer: 4

Which file contains information about the app?





✅ Correct Answer: 2

Which statement correctly assigns the id to textView element in layout file?





✅ Correct Answer: 2

AndroidMainfest.xml file contains the following essential information about your app: (choose all that apply)





✅ Correct Answer: 4

The strings.xml has a _________ element, which contains one or more elements.





✅ Correct Answer: 3

A layout can retrieve the value of the String named 'stringmessage' using `____`.





✅ Correct Answer: 3

The best practice is to put string values in _________ file.





✅ Correct Answer: 1

Buttons and text views both inherit from the same Android class named _____.





✅ Correct Answer: 3

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?





✅ Correct Answer: 2

Which of the following correctly adds a string array resource to strings.xml?





✅ Correct Answer: 3

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?





✅ Correct Answer: 2

Which of the following can you use to display a progress bar in an Android application?





✅ Correct Answer: 2

One can declare a logical parent ".MainActivity" to < activity > by adding the following line in the respective < activity > in AndroidManifest.xml.





✅ Correct Answer: 1

Which of the following lifecycle methods are common to both Activity and Fragment?





✅ Correct Answer: 2