Professional Documents
Culture Documents
Android How To Program 3rd Edition Deitel Test Bank
Android How To Program 3rd Edition Deitel Test Bank
4.3.1 Menus
Q1. You override Activity method ________ and use the method’s Menu argument
to add the menu items—either programmatically or by inflating an XML document
that describes the menu items.
a. on-Create-Menu
b. on-Create-OptionsMenu
c. on-OptionsMenuOpened
d. on-MenuOpened
Answer: b. on-Create-OptionsMenu
Q2. When the user selects a menu item, Activity method ________ responds to the
selection.
a. onItemSelected
b. onOptionsItemSelected
c. onOptionSelected
d. onMenuItemSelected
Answer: c. onOptionsItemSelected
4.3.5 Preferences
Q1. Which of the following statements is false?
a. A PreferenceFragment uses Preference objects to manage app settings and
stores those settings in a file via a SharedPreferences object.
b. A ListPreference creates checkboxes in which only one can be selected.
c. A MultiSelectListPreference creates a GUI containing checkboxes, any
number of which can be selected.
d. To modify a SharedPreferences file’s contents, you’ll use a SharedPrefer-
ences.Editor object.
Answer: b. A ListPreference creates checkboxes in which only one can be se-
lected. Actually, a ListPreference creates mutually exclusive radio buttons in
which only one can be selected.
© Copyright 2017 by Pearson Education, Inc. All Rights Reserved.
4.3.6 assets Folder
Q1. Files in the assets subfolders are accessed via an ________, which can provide
a list of all of the file names in a specified subfolder and can be used to access each
asset.
a. FolderManager
b. Organizer
c. AssetOrganizer
d. AssetManager
Answer: d. AssetManager
Q2. Resource folder names that begin with ________ contain XML files that define
property animations, which change the value of an object’s property over time.
a. animator
b. anim
c. animation
d. None of the above.
Answer: a. animator
4.3.15 AlertDialog
Q1. Which of the following statements about a standard AlertDialog is false?
a. Its negative action button cancels the dialog’s specified action, often labeled with
CANCEL- or NO. This is the leftmost button when there are multiple buttons in the
dialog.
b. Its positive action button accepts the dialog’s specified action, often labeled with
OK or YES. This is the rightmost button when there are multiple buttons in the dia-
log.
c. Its neutral action button indicates that the user does not want to cancel or accept
the action specified by the dialog. For example, an app that asks the user to register
to gain access to additional features might provide a REMIND ME LATER neutral
button.
© Copyright 2017 by Pearson Education, Inc. All Rights Reserved.
d. Each of the above statements is true.
Answer: d. Each of the above statements is true.
Q4. If multiple activities can handle the action and data passed to startActivity,
the system will ________.
a. display a dialog in which the user can select the activity to use
b. choose the first matching Activity
c. select a random Activity
d. None of the above
© Copyright 2017 by Pearson Education, Inc. All Rights Reserved.
Answer: a. display a dialog in which the user can select the activity to use
Q5. If the system cannot find an activity to handle an Intent’s action, then method
startActivity throws an Activity-NotFound-Exception. You can prevent this
exception from happening by first using Intent method ________ to determine
whether there is an Activity to handle the Intent.
a. findActivity
b. findActivityForIntent
c. resolveActivity
d. resolveActivityForIntent
Answer: c. resolveActivity
4.3.20 AndroidManifest.xml
Q1. Which of the following three statements is false?
a. You must create the AndroidManifest.xml file when you create an app.
b. All activities in an Android app must be listed in the app’s manifest file.
© Copyright 2017 by Pearson Education, Inc. All Rights Reserved.
c. When you add an activity to a project, the IDE will also add it to the manifest file.
d. All of the above statements are false.
Answer: a. You must create the AndroidManifest.xml file when you create an
app. Actually, the AndroidManifest.xml file is created for you when you create
an app.
Q3. When you choose the Blank Activity template’s Fragment option, this file con-
tains only a ________ element that displays the MainActivityFragment’s GUI
defined in fragment_main.xml.
a. <fragment_main>
b. <fragment>
c. <main_fragment>
d. None of the above
Answer: c. <fragment>
4.4.6 arrays.xml
Q1. By convention array resources are normally defined in arrays.xml, colors in
colors.xml, Strings in strings.xml and numeric values in ________.
a. numbers.xml
b. numeric.xml
c. digits.xml
d. values.xml
Answer: d. values.xml
4.4.7 colors.xml
Q1. As with any other resource, color resources should be defined in XML so you
can easily change colors without modifying your app’s Java source code and so you
can use Android’s ________ capabilities to provide colors resources for various sce-
narios (different locales, night and day colors, and so on).
a. color-choosing
b. value-choosing
c. locale-choosing
d. resource-choosing
Answer: d. resource-choosing
4.4.8 button_text_color.xml
Q1. When a color state list resource is provided for a Button color (either fore-
ground or background), the appropriate color from the list of colors is selected, based
on the Button’s ________.
a. relative horizontal position
b. importance
c. proximity to other GUI elements
d. state
Answer: d. state.
© Copyright 2017 by Pearson Education, Inc. All Rights Reserved.
4.4.9 Editing menu_main.xml
Q1. Select File > New > Vector Asset to display the ________—this tool enables you
to add to your project any of Google’s recommended material design icons. Each
icon is defined as a scalable vector graphic that smoothly scales to any size.
a. Vector Image Studio
b. Vector Asset Studio
c. Asset Studio
d. Image Studio
Answer: b. Vector Asset Studio
Q2. You can force a menu item to display on the app bar, in which case it’s known as
a(n) ________—by default, this is displayed as the menu item’s icon (if there is one).
a. task
b. button
c. action
d. None of the above
Answer: c. action
4.4.10
Q1. A(n) ________ is a collection of animations that make up a larger animation.
a. animation list
b. animation set
c. animation map
d. None of the above
Answer: b. animation set
Q2. Which of the following is not a tweened animation that you can include in an
animation set?
a. alpha
b. scale
c. rotate
d. flip
Answer: d. flip
Q4. The ________ attribute specifies how long the animation lasts in milliseconds.
a. android:duration
b. android:length
c. android:playbackTime
d. android:time
© Copyright 2017 by Pearson Education, Inc. All Rights Reserved.
Answer: a. android:duration
Q2. By default, the IDE set the layout’s Padding Left and Padding Right properties to
a predefined dimension resource named
© Copyright 2017 by Pearson Education, Inc. All Rights Reserved.
@dimen/activity_horizontal_margin—located in the ________ file of the pro-
ject’s res/values folder.
a. dimensions.xml
b. values.xml
c. strings.xml
d. dimens.xml
Answer: d. dimens.xml
Q3. Setting the layout:height property to 0dp will let a View’s height be determined
by the ________ property.
a. layout:weight
b. layout:width
c. layout:automatic
d. None of the above
Answer: a. layout:weight
Q4. Setting the ImageView’s adjustViewBounds property to true indicates that the
ImageView maintains its image’s ________.
a. width
b. height
c. resolution
d. aspect ratio
Answer: d. aspect ratio
Q5. It’s considered a best practice in Android to ensure that every GUI component
can be used with TalkBack. For components that don’t have descriptive text, such as
Image-Views, set the component’s ________ property.
a. description
b. contentDescription
c. talkback
d. talkbackDescription
Answer: b. contentDescription
4.6.2 Fields
No questions.
4.7.2 Fields
No questions.
Q2. You can use a(n) ________ object to delay the performance of an action.
a. DelayedAction
b. ActionHandler
c. TaskHandler
d. Handler
Answer: d. Handler
4.10 AndroidManifest.xml
Q1. Which of the following is false?
a. Each Activity in an app must be declared in AndroidManifest.xml; otherwise,
Android will not know that the Activity- exists and will not be able to launch it.
b. By default each Activity you create uses the "standard" launch mode. In this
mode, when Android receives an Intent to launch the Activity, Android creates a
new instance of that Activity
c. With MainActivity’s launchMode set to "singleTop", when the user touches
the up button Android brings the existing MainActivity to the foreground, rather
than creating a new MainActivity object.
d. Each of the above is true.
Answer: d. Each of the above is true.