wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AND-401

Total questions: 60

Worksheet time: 32mins

Name
Class
Date
1.

The values of which of the following classes cannot be mapped in a Bundle object?

a)

Parcelable objects

b)

Primitive data types

c)

Serializable objects

d)

Context

2.

Which of the following AsyncTask methods is NOT executed on the UI thread?

a)

onPreExecute()

b)

onPostExecute()

c)

publishProgress()

d)

onProgressUpdate()

3.

Which one of the following is not a valid name for process state?

a)

Bound

b)

Visible

c)

Foreground

d)

Background

4.

AppCompayActivity is the base class for activities that use action bar features of the support library?

a)

True

b)

False

5.

Which of the following does not have a ContenProvider component provided natively by Android SDK?

a)

The contacts list

b)

The telephone log

c)

The bookmarks

d)

The application list

6.

Which of the following contents of file /res/value/style.xml correctly applies to the Light Material Theme to your application?

a)

<resources>

</style name=”AppLightTheme” parent=”android: Theme.Material”>

</style>

</resources>

b)

<resources>

</style name=”MyAppTheme” parent=”android: Theme.Material.Light”>

</style>

</resources>

c)

<resources>

</style name=”AppTheme” parent=”android: Theme.Material”>

</style>

</resources>

d)

<resources>

</style name=”AppLightTheme” parent=”android: Theme.Material.Light”>

</style>

</resources>

7.

Which of the following is NOT correct about the Gradle build system of Android Studio?

a)

The Gradle build file is called build.gradle

b)

Gradle supports generating only one build variant

c)

Gradle uses the Groovy syntax to configure the build

d)

A build is configured by using elements provided by the Android plugin for Gradle

8.

Which of the following Activity life-cycle methods is invoked when another activity is shown?

a)

onPause()

b)

onCreate()

c)

onStop()

d)

onDestroy()

9.

Which of the following Material Theme attributes are used to custom the color palette in your application? (Choose Three)

a)

android: colorAccent

b)

android: colorPrimary

c)

android: colorPrimaryText

d)

android: colorPrimaryDark

10.

Which of the following adds a click listener to items in a ListView?

a)

setonClickListener

b)

setonItemClickListener

c)

setonItemClicked

d)

setonListItemClickListener

11.

Which one of the following statements is NOT a function of the Action Bar?

a)

It provides a dedicated space on the screen to identify the current activity to the user

b)

It facilitates the accessibility to important application actions

c)

It loads web URLs to display HTML pages

d)

It supports consistent navigation and view switching within apps

12.

Which of the following are layout-related methods called by the framework on views, and you can override them when customizing a view? (Choose two)

a)

onMeasure()

b)

onDraw()

c)

onKeyUp()

d)

onSizeChanged()

13.

Which of the following is true about this code snippet? (Choose two)

Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse(“tel:555-1234”));

startActivity(intent);

a)

This is an explicit intent that start the system’s dialer

b)

The system will not dial the number without adding permission CALL_PHONE.

c)

The system will perform an intent resolution to start the proper activity

d)

The code will not compile

14.

Which of the following is a valid sequence of invokes to Activity lifecycle methods? (Select Two)

a)

onCreate > onStart > onResume > onPause> onStop> onCreate

b)

onCreate > onStart > onResume > onPause> onStop>onRestart

c)

onCreate > onStart > onResume > onPause> onStop>onDestroy

d)

onCreate > onStart > onResume > onPause> onStop>onResume

15.

Which of the following applies a context menu on a ListView (Choose two)?

a)

ListView lv = getListView();

lv.registerForContextMenu()

b)

ListView lv = getListView();

registerForContextMenu(lv);

c)

ListView lv = (ListView) findViewByld(R.id.list_view_id);

registerForContextMenu(lv)

d)

getListView().setContextMenuEnabled(true)

16.

Which of the following best explains the Android context menus?

a)

It is a popup menu displays a list of items in a vertical list that’s anchored to the view that invoked the menu.

b)

It is a floating menu that appears when the user performs a long-click on an element. It provides actions that affect the selected content or context frame.

c)

It is the primary collection of menu items for an activity. It’s where you should place actions that have a global impact on the app, such as “Search”, “Compose email”, and “Settings”.

d)

It is a sub-menu of an options menu item

17.

Which of the following is NOT a feature provided by the Material Theme?

a)

System widgets that let you set their color palette.

b)

Adding a fragment component to layout.

c)

Activity transition animations.

d)

Touch feedback animations for the system widgets.

18.

Which of the following statements is NOT correct about Android fragments?

a)

Which of the following statements is NOT correct about Android fragments?

b)

The life-cycle of a fragment is totally independent of the activity hosting it

c)

Fragments have their own life-cycle

d)

You can add/remove fragments to and an activity dynamically, i.e. while the activity is running

19.

Which of the following are benefits for using fragments in your application? (Choose two)

a)

Simplify the reusability of UI components.

b)

Build different layouts for different device configurations.

c)

Add an action bar to your application.

d)

Dynamically add and remove UI components to an activity.

20.

Which of the following you cannot achieve by creating your own View sub-classes?

a)

Create a completely new customized View type

b)

Combine a group of View components into a new single component

c)

Specify when to destroy an activity and all its views

d)

Specify when to destroy an activity and all its views

21.

Which of the following is NOT true about method getWindow() of class Dialog?

a)

It retrieves the current window for the activity

b)

It can be used to access parts of the Window API

c)

It displays the dialog on the screen

d)

It returns null if the activity is not visible

22.

Which of the following best defines an Android fragment?

a)

It is a portion of the user-interface that is embedded in an activity.

b)

It is the component that allows asynchronous loading of data into an activity

c)

It is an XML file that defines the layout of an activity

d)

It is a type of a drawable resource file

23.

What is the location of APK generated by the build system of Android Studio?

a)

app/build/apk

b)

app/apks

c)

app/build/outputs/apk

d)

app/intermediates/outputs/apk

24.

Which of the following lines of code is used to pass a value to the next activity?

a)

Intent i = new Intent(this,newActivity);

i.addExtra(“test”);

startActivity(i);

b)

Intent i = new Intent(this,newActivity);

i.putValue(“test”);

startActivity(i);

c)

Intent i = new Intent(this,newActivity);

i.putValue(“value1″,”test”);

startActivity(i);

d)

Intent i = new Intent(this,newActivity);

i.putExtra(“value1″,”test”);

startActivity(i);

25.

Which of the following sets the entire Activity window as a WebView?

a)

WebView webview = new WebView(this);

webview.setAsWindow;

b)

setContentView(R.layout.webview);

c)

WebView webview = new WebView(this);

setContentView(webview);

d)

setContentView(“http://www.androidatc.com”);

26.

Consider the following the code:

public boolean onCreateOptionsMenu(Menu menu) {

MenuInflater inflater = getMenuInflater();

inflater.inflate(R.menu.game_menu, menu);

return true;

}

Which of the following is true about the code above?

a)

The code is auto generated and should not be edited

b)

This method handles clicks and assign actions to menu items

c)

This function inflates an XML file in the res/menu folder into menu items

d)

This method inflates an XML file in the res/layout folder into layout

27.

Consider the following AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.mkyong.android"

android:versionCode="1"

android:versionName="1.0" >

<uses-sdk android:minSdkVersion="10" />

<uses-permission android:name="android.permission.WebActivity " />

<application

android:icon="@drawable/ic_launcher"

android:label="@string/app_name" >

<activity

android:name=".WebViewActivity"

android:theme="@android:style/Theme.NoTitleBar" >

<intent-filter >

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

</manifest>

Supposing the application connects to the internet at startup, which of the following is true?

a)

The application throws an exception indicating it does not have permission to access the URL

b)

The application will work as intended

c)

The application won’t compile

d)

The application throws a java.lang.SecurityException

28.

Which of the following is NOT true about using a WebView in your application?

a)

You can retrieve WebSettings with getSettings(), then enable/disable JavaScript

b)

You need to add permission “android.permission.ACCESS_NETWORK_STATE”

c)

You use loadURL to load a webpage

d)

You use loadData to load HTML

29.

Which of the following is NOT true about class AsyncTask?

a)

It must be used by sub-classing it

b)

It must be created on the UI thread

c)

Its sub-class override at least two methods: doInBackground, onPostExecute

d)

It uses three generic types

30.

What does the following line of code do?

Toast toast = Toast.makeText(this,"Android ATC", Toast.LENGTH_LONG);

toast.setGravity(Gravity.TOP|Gravity.RIGH, 0, 0);

a)

The toast will have it UI components place on the top-right corner

b)

The toast will appear on the top-right corner

c)

The toast will show the text message on top-right corner of the toast box

d)

The toast will appear at the center of the screen at position (0,0), but aligned to the top-right corner

31.

Which of the following is NOT true about a content provider?

a)

It manages access to structured data

b)

It cannot be used from inside an Activity

c)

It cannot be used from inside an Activity

d)

To access data in it, method getContentResolver() of the application’s Context is used

32.

Consider the following code snippet:

String[] result_columns = new String[] {KEY_ID, COL1, COL2};

Cursor allRows = myDatabase.query(true, DATABASE_TABLE, result_columns,

null, null, null, null, null, null);

Which of the following prints out the values of COL1 column correctly if the result is not empty?

a)

if (cursor.moveToFirst()) {

do {

System.out.println(cursor.getString(1));

} while (cursor.moveToNext());

}

b)

do {

System.out.println(cursor.getString(0));

} while (cursor.moveToNext());

c)

if (cursor.moveToFirst()) {

do {

System.out.println(cursor.getString(0));

} while (cursor.moveToNext()); }

d)

if (cursor != null) {

do {

System.out.println(cursor.getString(1));

} while (!cursor.isNull());

}

33.

Which of the following is NOT true about SQLiteOperHelper class? (Choose two)

a)

It has two abstract methods: onCreate() and onUpgrade().

b)

It is used to perform database querying.

c)

It manages database creation and updates

d)

It manages database versions using ContentProvider

34.

Which of the following is a rule that developers must always follow when writing multi-threaded Android applications? (Choose two)

a)

A worker thread must not be created from inside the UI thread

b)

Each UI thread must not create more than one worker thread

c)

The UI thread must never be blocked

d)

The Android UI must not be accessed from outside the UI thread

35.

To create a customized Adapter for a compound list item layout, you should:

a)

Extend class android.widget.Adapter or any of its descendants then override method getView()

b)

Extend class android.widget.ListView or any of its descendants, then override method getView()

c)

Extend class android.widget.AbsAdapter or any of its descendants, then override method getView()

d)

Extend class android.widget.Adapter or any of its descendants, then override method getAdapterView()

36.

When publishing an update to your application to the market, the following must be taken into consideration:

a)

The package name must be the same, but the .apk may be signed with a different private key

b)

The package name does not have to be the same and the .apk can be signed with a different private key

c)

The package name must be the same and the .apk must be signed with the same private key

d)

The package name does not have to be the same, but the .apk must be signed with the same private key

37.

Which of these is the incorrect method for an Application to save local data?

a)

Extend PreferencesActivity and save in an XML file.

b)

Save as a file in the local file system

c)

Save in the database using SQLite

d)

Save in the hash table file using the Dictionary class

38.

Which UI does the following code builds?

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=http://

schemas.android.com/apk/res/android

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal" >

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Name:" />

<EditText

android:id="@+id/editText1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:ems="10" />

</LinearLayout>

<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Post" />

</LinearLayout>

a)

An edit text to the left of a text view and a button beneath it

b)

An edit text to the right of a text view and a button to the right of the text view

c)

An edit text to the right of a text view and a button beneath them

d)

A text view, an edit text beneath it and the button beneath the edit text

39.

Consider the following code:

Intent i = new Intent(this, MainActivity.class);

i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

startActivity(i);

What best explains the code above?

a)

The activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

b)

Any existing task that would be associated with the activity to be cleared before the activity is started

c)

A new Activity will be launched and it will be on the top of the stack

d)

A new activity will be launched but will be in full-screen mode

40.

To add a new Activity to your application, you need to perform the following steps:

a)

Create a Java class that extends View, set a layout, and add an Activity tag in AndroidManifest.xml

b)

Create layout resource only

c)

Create a Java class that extends Activity, add an Activity tag in AndroidManifest.xml, and create a layout for the activity

d)

Add an Activity tag to AndroidManifest.xml, and add ACTIVITY permission

41.

Method onDraw() of class android.view.View has the following signature

a)

public void onDraw(Color)

b)

public void onDraw(Canvas)

c)

public boolean onDraw(Canvas)

d)

public Canvas onDraw()

42.

Which of these is the correct explanation regarding the following methods?

(1)android.content.Context.sendBroadcast

(2)android.content.Context.startActivity

a)

Both methods are defined by overloading

b)

Both methods throw an exception

c)

Both methods are asynchronous

d)

Both methods are able to broadcast an Intent

43.

Which of the following is incorrect about ProgressDialog?

a)

ProgressDialog inherits from the AlertDialog class.

b)

ProgressDialog can be set as 2 types of style: STYLE_HORIZONTAL and STYLE_SPINNER.

c)

ProgressDialog is able to apply a custom XML-defined layout by using the setContentView(…) method.

d)

ProgressDialog can be freely configured to use a Drawable class to display as its progress bar

44.

Which of these is the correct function of Traceview?

a)

Displays a graphical task execution log

b)

Displays graphically a memory acquisition and release log

c)

Displays graphically the call stack

d)

Displays graphically the Ul state hierarchy

45.

Which of the following is the correct way to add access permission to your application?

a)

Add a <uses-permission> tag as a child tag of the <manifest> tag in AndroidManifest.xml

b)

Add a <add-permission> tag as a child tag of the <manifest> tag in AndroidManifest.xml

c)

Add a <add-permission> tag as a child tag of the <manifest> tag in AndroidManifest.xml

d)

add a <permission> tag as a child tag of the <application> tag in AndroidManifest.xml

46.

Which of the following statements is correct about SQLite?

a)

It is an object database

b)

It is client-server format

c)

It is possible to create and access a database by using SQLOpenHelper

d)

It can be accessed by other applications through ContentProvider

47.

When including a text file in your application to read from as a resource, what is the recommended location of such file?

a)

res/anim

b)

res/files

c)

res/raw

d)

res/values

48.

Which of the following statements about DDMS is incorrect?

a)

You can display a list of currently running threads and select one to check its stack trace

b)

You can use it to acquire screenshots of a terminal

c)

You can forcibly execute garbage collection and check the present heap usage status

d)

You can do simulations of network zone speed and bandwidth limitations

49.

Which of the following is incorrect about intents?

a)

They can be used to start an Activity

b)

They can be used to start a service

c)

They can be used to start database insertion

d)

They can be used to start a dialog-themed activity

50.

In which Activity life-cycle method you should do all of your normal static set up such as: creating views and bind data to lists?

a)

onResume()

b)

onStart()

c)

onCreate()

d)

onPause()

51.

Which of the following lines of code starts activity Activity2 from a current activity Activity1?

a)

Intent intent = new Intent(this,new Activity2());

startActivity(intent);

b)

Intent intent = new Intent(new Activity2());

startActivity(intent);

c)

Intent intent = new Intent (Activity1.class,Activity2.class);

startActivity(intent);

d)

Intent intent = new Intent(this,Activity2.class);

startActivity(intent);

52.

Which of the following methods is called in an Activity when another activity gets into the foreground?

a)

onStop()

b)

onPause()

c)

onDestroy()

d)

onExit()

53.

Which of the following attributes is used to set an activity screen to landscape orientation?

a)

screenorientation = landscape

b)

screenOrientation=”landscape”

c)

android:ScreenOrientation=”landscape”

d)

android:screenOrientation=”landscape”

54.

What is not true about the AndroidManifest.xml file?

a)

It declares the views used within the application

b)

It declares user permissions the application requires

c)

It declares application components

d)

It declares hardware and software features used within the application

55.

If your application is throwing the exception android.content.ActivityNotFoundException, how to fix it?

a)

Create a new activity Java sub-class

b)

Rename your activity

c)

Create the activity layout

d)

Add the activity to the AndroidManifest

56.

Consider the following code:

Intent intent = new Intent();

intent.setAction(Intent.ACTION_VIEW);

intent.setData(android.net.Uri.parse("http://www.androidatc.com"));

startActivity(intent);

Which of the following is correct about the code above?

a)

It sends a result to a new Activity in a Bundle.

b)

It will not compile without adding the INTERNET permission the Manifest file

c)

It starts any activity in the application that has a WebView in its layout

d)

When it is executed, the system starts an intent resolution process to start the right Activity

57.

Which of the following is not true about <activity> tag in AndroidManifest file?

a)

Declares an activity that implements part of the application’s visual user interface

b)

Contained in <application> tag

c)

Declares a single hardware or software feature that is used by the application

d)

Has an attribute that specifies the name of the Activity sub-class that implements the activity

58.

Which of these is NOT recommended in the Android Developer’s Guide as a method of creating an individual View?

a)

Create by extending the android.view.View class

b)

Create by extending already existing View classes such as Button or TextView

c)

Create by copying the source of an already existing View class such as Button or TextView

d)

Create by combining multiple Views

59.

Which of these is the incorrect explanation of the Android SDK and AVD Manager?

a)

They are provided from version 1.6 of the SDK. Up to Version 1.5, there was an AVD Manager but it lacked SDK management functions.

b)

You can create and startup AVD, and on startup you can delete user data up to that point

c)

The "android" command can be used if "<SDK install folder>/tools" is added to the command path

d)

The development tools that can be downloaded from Android SDK and AVD Manager are SDK Android platform, NDK-platform, emulator images, and USB drivers for handsets

60.

Which of the following is correct about file access in the Android system?

a)

Generally, files are handled as dedicated resources per each application

b)

Files created by an application can be directly accessed by any application

c)

The content of file created by application cannot be accessed by any other application

d)

You can only access a file from within an Activity