Font size
WorksheetsAND-401
Total questions: 60
Worksheet time: 32mins
The values of which of the following classes cannot be mapped in a Bundle object?
Parcelable objects
Primitive data types
Serializable objects
Context
Which of the following AsyncTask methods is NOT executed on the UI thread?
onPreExecute()
onPostExecute()
publishProgress()
onProgressUpdate()
Which one of the following is not a valid name for process state?
Bound
Visible
Foreground
Background
AppCompayActivity is the base class for activities that use action bar features of the support library?
True
False
Which of the following does not have a ContenProvider component provided natively by Android SDK?
The contacts list
The telephone log
The bookmarks
The application list
Which of the following contents of file /res/value/style.xml correctly applies to the Light Material Theme to your application?
<resources>
</style name=”AppLightTheme” parent=”android: Theme.Material”>
</style>
</resources>
<resources>
</style name=”MyAppTheme” parent=”android: Theme.Material.Light”>
</style>
</resources>
<resources>
</style name=”AppTheme” parent=”android: Theme.Material”>
</style>
</resources>
<resources>
</style name=”AppLightTheme” parent=”android: Theme.Material.Light”>
</style>
</resources>
Which of the following is NOT correct about the Gradle build system of Android Studio?
The Gradle build file is called build.gradle
Gradle supports generating only one build variant
Gradle uses the Groovy syntax to configure the build
A build is configured by using elements provided by the Android plugin for Gradle
Which of the following Activity life-cycle methods is invoked when another activity is shown?
onPause()
onCreate()
onStop()
onDestroy()
Which of the following Material Theme attributes are used to custom the color palette in your application? (Choose Three)
android: colorAccent
android: colorPrimary
android: colorPrimaryText
android: colorPrimaryDark
Which of the following adds a click listener to items in a ListView?
setonClickListener
setonItemClickListener
setonItemClicked
setonListItemClickListener
Which one of the following statements is NOT a function of the Action Bar?
It provides a dedicated space on the screen to identify the current activity to the user
It facilitates the accessibility to important application actions
It loads web URLs to display HTML pages
It supports consistent navigation and view switching within apps
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)
onMeasure()
onDraw()
onKeyUp()
onSizeChanged()
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);
This is an explicit intent that start the system’s dialer
The system will not dial the number without adding permission CALL_PHONE.
The system will perform an intent resolution to start the proper activity
The code will not compile
Which of the following is a valid sequence of invokes to Activity lifecycle methods? (Select Two)
onCreate > onStart > onResume > onPause> onStop> onCreate
onCreate > onStart > onResume > onPause> onStop>onRestart
onCreate > onStart > onResume > onPause> onStop>onDestroy
onCreate > onStart > onResume > onPause> onStop>onResume
Which of the following applies a context menu on a ListView (Choose two)?
ListView lv = getListView();
lv.registerForContextMenu()
ListView lv = getListView();
registerForContextMenu(lv);
ListView lv = (ListView) findViewByld(R.id.list_view_id);
registerForContextMenu(lv)
getListView().setContextMenuEnabled(true)
Which of the following best explains the Android context menus?
It is a popup menu displays a list of items in a vertical list that’s anchored to the view that invoked the menu.
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.
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”.
It is a sub-menu of an options menu item
Which of the following is NOT a feature provided by the Material Theme?
System widgets that let you set their color palette.
Adding a fragment component to layout.
Activity transition animations.
Touch feedback animations for the system widgets.
Which of the following statements is NOT correct about Android fragments?
Which of the following statements is NOT correct about Android fragments?
The life-cycle of a fragment is totally independent of the activity hosting it
Fragments have their own life-cycle
You can add/remove fragments to and an activity dynamically, i.e. while the activity is running
Which of the following are benefits for using fragments in your application? (Choose two)
Simplify the reusability of UI components.
Build different layouts for different device configurations.
Add an action bar to your application.
Dynamically add and remove UI components to an activity.
Which of the following you cannot achieve by creating your own View sub-classes?
Create a completely new customized View type
Combine a group of View components into a new single component
Specify when to destroy an activity and all its views
Specify when to destroy an activity and all its views
Which of the following is NOT true about method getWindow() of class Dialog?
It retrieves the current window for the activity
It can be used to access parts of the Window API
It displays the dialog on the screen
It returns null if the activity is not visible
Which of the following best defines an Android fragment?
It is a portion of the user-interface that is embedded in an activity.
It is the component that allows asynchronous loading of data into an activity
It is an XML file that defines the layout of an activity
It is a type of a drawable resource file
What is the location of APK generated by the build system of Android Studio?
app/build/apk
app/apks
app/build/outputs/apk
app/intermediates/outputs/apk
Which of the following lines of code is used to pass a value to the next activity?
Intent i = new Intent(this,newActivity);
i.addExtra(“test”);
startActivity(i);
Intent i = new Intent(this,newActivity);
i.putValue(“test”);
startActivity(i);
Intent i = new Intent(this,newActivity);
i.putValue(“value1″,”test”);
startActivity(i);
Intent i = new Intent(this,newActivity);
i.putExtra(“value1″,”test”);
startActivity(i);
Which of the following sets the entire Activity window as a WebView?
WebView webview = new WebView(this);
webview.setAsWindow;
setContentView(R.layout.webview);
WebView webview = new WebView(this);
setContentView(webview);
setContentView(“http://www.androidatc.com”);
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?
The code is auto generated and should not be edited
This method handles clicks and assign actions to menu items
This function inflates an XML file in the res/menu folder into menu items
This method inflates an XML file in the res/layout folder into layout
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?
The application throws an exception indicating it does not have permission to access the URL
The application will work as intended
The application won’t compile
The application throws a java.lang.SecurityException
Which of the following is NOT true about using a WebView in your application?
You can retrieve WebSettings with getSettings(), then enable/disable JavaScript
You need to add permission “android.permission.ACCESS_NETWORK_STATE”
You use loadURL to load a webpage
You use loadData to load HTML
Which of the following is NOT true about class AsyncTask?
It must be used by sub-classing it
It must be created on the UI thread
Its sub-class override at least two methods: doInBackground, onPostExecute
It uses three generic types
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);
The toast will have it UI components place on the top-right corner
The toast will appear on the top-right corner
The toast will show the text message on top-right corner of the toast box
The toast will appear at the center of the screen at position (0,0), but aligned to the top-right corner
Which of the following is NOT true about a content provider?
It manages access to structured data
It cannot be used from inside an Activity
It cannot be used from inside an Activity
To access data in it, method getContentResolver() of the application’s Context is used
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?
if (cursor.moveToFirst()) {
do {
System.out.println(cursor.getString(1));
} while (cursor.moveToNext());
}
do {
System.out.println(cursor.getString(0));
} while (cursor.moveToNext());
if (cursor.moveToFirst()) {
do {
System.out.println(cursor.getString(0));
} while (cursor.moveToNext()); }
if (cursor != null) {
do {
System.out.println(cursor.getString(1));
} while (!cursor.isNull());
}
Which of the following is NOT true about SQLiteOperHelper class? (Choose two)
It has two abstract methods: onCreate() and onUpgrade().
It is used to perform database querying.
It manages database creation and updates
It manages database versions using ContentProvider
Which of the following is a rule that developers must always follow when writing multi-threaded Android applications? (Choose two)
A worker thread must not be created from inside the UI thread
Each UI thread must not create more than one worker thread
The UI thread must never be blocked
The Android UI must not be accessed from outside the UI thread
To create a customized Adapter for a compound list item layout, you should:
Extend class android.widget.Adapter or any of its descendants then override method getView()
Extend class android.widget.ListView or any of its descendants, then override method getView()
Extend class android.widget.AbsAdapter or any of its descendants, then override method getView()
Extend class android.widget.Adapter or any of its descendants, then override method getAdapterView()
When publishing an update to your application to the market, the following must be taken into consideration:
The package name must be the same, but the .apk may be signed with a different private key
The package name does not have to be the same and the .apk can be signed with a different private key
The package name must be the same and the .apk must be signed with the same private key
The package name does not have to be the same, but the .apk must be signed with the same private key
Which of these is the incorrect method for an Application to save local data?
Extend PreferencesActivity and save in an XML file.
Save as a file in the local file system
Save in the database using SQLite
Save in the hash table file using the Dictionary class
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>
An edit text to the left of a text view and a button beneath it
An edit text to the right of a text view and a button to the right of the text view
An edit text to the right of a text view and a button beneath them
A text view, an edit text beneath it and the button beneath the edit text
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?
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.
Any existing task that would be associated with the activity to be cleared before the activity is started
A new Activity will be launched and it will be on the top of the stack
A new activity will be launched but will be in full-screen mode
To add a new Activity to your application, you need to perform the following steps:
Create a Java class that extends View, set a layout, and add an Activity tag in AndroidManifest.xml
Create layout resource only
Create a Java class that extends Activity, add an Activity tag in AndroidManifest.xml, and create a layout for the activity
Add an Activity tag to AndroidManifest.xml, and add ACTIVITY permission
Method onDraw() of class android.view.View has the following signature
public void onDraw(Color)
public void onDraw(Canvas)
public boolean onDraw(Canvas)
public Canvas onDraw()
Which of these is the correct explanation regarding the following methods?
(1)android.content.Context.sendBroadcast
(2)android.content.Context.startActivity
Both methods are defined by overloading
Both methods throw an exception
Both methods are asynchronous
Both methods are able to broadcast an Intent
Which of the following is incorrect about ProgressDialog?
ProgressDialog inherits from the AlertDialog class.
ProgressDialog can be set as 2 types of style: STYLE_HORIZONTAL and STYLE_SPINNER.
ProgressDialog is able to apply a custom XML-defined layout by using the setContentView(…) method.
ProgressDialog can be freely configured to use a Drawable class to display as its progress bar
Which of these is the correct function of Traceview?
Displays a graphical task execution log
Displays graphically a memory acquisition and release log
Displays graphically the call stack
Displays graphically the Ul state hierarchy
Which of the following is the correct way to add access permission to your application?
Add a <uses-permission> tag as a child tag of the <manifest> tag in AndroidManifest.xml
Add a <add-permission> tag as a child tag of the <manifest> tag in AndroidManifest.xml
Add a <add-permission> tag as a child tag of the <manifest> tag in AndroidManifest.xml
add a <permission> tag as a child tag of the <application> tag in AndroidManifest.xml
Which of the following statements is correct about SQLite?
It is an object database
It is client-server format
It is possible to create and access a database by using SQLOpenHelper
It can be accessed by other applications through ContentProvider
When including a text file in your application to read from as a resource, what is the recommended location of such file?
res/anim
res/files
res/raw
res/values
Which of the following statements about DDMS is incorrect?
You can display a list of currently running threads and select one to check its stack trace
You can use it to acquire screenshots of a terminal
You can forcibly execute garbage collection and check the present heap usage status
You can do simulations of network zone speed and bandwidth limitations
Which of the following is incorrect about intents?
They can be used to start an Activity
They can be used to start a service
They can be used to start database insertion
They can be used to start a dialog-themed activity
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?
onResume()
onStart()
onCreate()
onPause()
Which of the following lines of code starts activity Activity2 from a current activity Activity1?
Intent intent = new Intent(this,new Activity2());
startActivity(intent);
Intent intent = new Intent(new Activity2());
startActivity(intent);
Intent intent = new Intent (Activity1.class,Activity2.class);
startActivity(intent);
Intent intent = new Intent(this,Activity2.class);
startActivity(intent);
Which of the following methods is called in an Activity when another activity gets into the foreground?
onStop()
onPause()
onDestroy()
onExit()
Which of the following attributes is used to set an activity screen to landscape orientation?
screenorientation = landscape
screenOrientation=”landscape”
android:ScreenOrientation=”landscape”
android:screenOrientation=”landscape”
What is not true about the AndroidManifest.xml file?
It declares the views used within the application
It declares user permissions the application requires
It declares application components
It declares hardware and software features used within the application
If your application is throwing the exception android.content.ActivityNotFoundException, how to fix it?
Create a new activity Java sub-class
Rename your activity
Create the activity layout
Add the activity to the AndroidManifest
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?
It sends a result to a new Activity in a Bundle.
It will not compile without adding the INTERNET permission the Manifest file
It starts any activity in the application that has a WebView in its layout
When it is executed, the system starts an intent resolution process to start the right Activity
Which of the following is not true about <activity> tag in AndroidManifest file?
Declares an activity that implements part of the application’s visual user interface
Contained in <application> tag
Declares a single hardware or software feature that is used by the application
Has an attribute that specifies the name of the Activity sub-class that implements the activity
Which of these is NOT recommended in the Android Developer’s Guide as a method of creating an individual View?
Create by extending the android.view.View class
Create by extending already existing View classes such as Button or TextView
Create by copying the source of an already existing View class such as Button or TextView
Create by combining multiple Views
Which of these is the incorrect explanation of the Android SDK and AVD Manager?
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.
You can create and startup AVD, and on startup you can delete user data up to that point
The "android" command can be used if "<SDK install folder>/tools" is added to the command path
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
Which of the following is correct about file access in the Android system?
Generally, files are handled as dedicated resources per each application
Files created by an application can be directly accessed by any application
The content of file created by application cannot be accessed by any other application
You can only access a file from within an Activity
