NEW
Font size
WorksheetsAndroid Development Associate
Total questions: 40
Worksheet time: 1hrs 29mins
What Activity method you use to retrieve a reference to an Android view by using the id attribute of a resource XML?
findViewByReference(int id)
retrieveResourceById(int id)
findViewById(int id)
findViewById(String id)
During an Activity life-cycle, what is the first callback method invoked by the system?
onCreate()
onStart()
onStop()
onRestore()
What does the following line of code achieve?
Intent intent = new Intent(FirstActivity.this, SecondActivity.class );
Starts an activity
Creates an implicit Intent.
Creates a hidden Intent.
Create an explicit Intent.
Which of the following is NOT a valid usage for Intents?
Activate a SQLite DB Connection.
Activate a Broadcast receiver.
Activate a Service.
Activate and Activity.
What is the parent class of all Activity widgets?
Layout
ViewGroup
View
Widget
What is the name of the class used by Intent to store additional information?
Parcelable
DataStore
Extra
Bundle
You can create a custom view by extending class Activity.
True
False
What does the Android project folder “res/” contain?
Resource files
Java Activity classes
Java source code
Libraries
What does this code do?
Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(android.net.Uri.parse("http://www.androidatc.com")); startActivity(intent);
Starts an activity using an implicit intent.
Sends results to another activity
Starts a sub-activity.
Starts a service
Which method should you use to start a sub-activity?
startSubActivity(Intent intent)
startService(Intent intent)
startActivity(Intent intent)
startActivityForResult(Intent intent)
Which Android permission you should add to allow your application to read the device’s address book?
READ_PHONE_STATE
READ_ADDRESS_DATA
READ_CONTACTS
READ_PHONE_CONTACTS
Which of the following methods is called in an Activity when another activity gets into the foreground?
onDestroy()
onStop()
onPause()
onExit()
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 hardware and software features used within the application.
It declares application components.
If your application is throwing exception android.content.ActivityNotFoundException, which of the following could resolve the problem?
Add the activity to AndroidManifest.xml
Create the activity layout
Create a new sub-class of the View class
Create a new broadcast receiver
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 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.
It sends a result to a new Activity in a Bundle
Which of the following Android View sub-classes uses the WebKit rendering engine to display web pages?
MapView
PageView
WebView
HttpClient
Which of the following is incorrect about intents?
They can be used to start an Activity
They can be used to start database insertion
They can be used to start a service
They can be used to start a dialog-themed activity
To create a blank Wear activity in Android Studio, the project should have a minimum SDK version >= 20
True
False
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);
Gradle is the build system used in Android Studio. It builds, tests, runs, and packages your apps
True
False
What method you should override to use Android menu system?
onCreateOptionsMenu()
onCreateMenu()
onMenuCreated()
onCreateContextMenu()
Which of these files contains text values that you can use in your application?
AndroidManifest.xml
res/Text.xml
res/layout/Main.xml
res/values/strings.xml
Which of the following is a Java call-back method invoked when a view is clicked?
Detector
OnTapListener
OnClickDetector
OnClickListener
Which of the following tools dumps system log messages including stack traces when the device or emulator throws an error?
DDMS
Logcat
Console
ADB
Which method should you use to start a sub-activity?
startActivity(Intent intent)
startActivityForResult(Intent intent)
startService(Intent intent)
startSubActivity(Intent intent)
Which package of the following does not have classes needed for Android network connections?
java.net
org.apache.http
android.location
android.net
What is the second layer from top called in the following diagram of Android’s Architecture?
Applications layer
Application framework
Linux kernel
Android runtime
Which of the following is not true about tag in AndroidManifest file?
Declares an activity that implements part of the application's visual user interface
Contained in 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 the following AsyncTask methods is NOT executed on the UI thread?
onPreExecute()
onPostExecute()
publishProgress()
onProgressUpdate()
Which of the following is a NOT valid form of notification invoked by the NotificationManager?
A Flashing LED.
A persistent icon in the status bar.
A sound played.
A SMS sent.
What does the src folder contain?
Image and icon files
XML resource files
The application manifest file
Java source code files
Which of the following is a correct Android Manifest
statement?
<uses-permission android:name =”android.Internet”/>
<uses-permission android:name =”android.Internet”></uses-permission>
<uses-permission android:name =”android.permission.Internet”>
<uses-permission android:name =”android. permission.Internet”/>
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”
Which of the following best explains the Android option menus?
It is a popup menu that displays a list of items in a vertical list 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 where you should place actions
that have a global impact on the app, such as "Search," "Compose email," and
"Settings."
It is a type of List Activity with predefined headers and footers for special commands.
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.
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Menu");
AdapterContextMenuInfo cmi = (AdapterContextMenuInfo) menuInfo;
menu.add(1, cmi.position, 0, "Open file");
menu.add(2, cmi.position, 0, "Save file");
}
The code inflates an xml file into menu items
The code creates menu items for context menu programmatically
The code assign actions to menu items
The code Opens a menu resource file, modifies it, and saves the changes.
Which of the following is true about method startActivity?
It starts a new activity and destroys the previous one
It starts a new activity and sends the previous one to the background.
It starts a new activity and pauses the previous one.
It starts a new activity in a paused mode.
Which of the following AsyncTask methods is NOT executed on the
UI thread?
onPreExecute()
onPostExecute()
publishProgress()
onProgressUpdate()
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 does NOT correctly describe interface
android.widget.Adapter?
It is an object that acts as a bridge between a View and underlying data for that view.
It provides access to the data items.
It provides access to deprecated ListView methods.
It is responsible for making a View for each item in the data set.
