Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Android How to Program Chapter 04


 

Download  file with the answers

If you are not a member register here to download this file 


Chapter 4

Flag Quiz App

4.2.2 Taking the Quiz
Q1. You must interact with a ________ dialog to dismiss it.
a. error
b. non-modal
c. modal
d. information

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

Q2. When the user selects a menu item, Activity method ________ responds to the selection.
a. onItemSelected
b. onOptionsItemSelected
c. onOptionSelected
d. onMenuItemSelected

4.3.2 Fragments
Q1. Which of the following statements is false?
a. A Fragment typically represents a reusable portion of an Activity’s user inter-face, but may also represent reusable program logic.
b. Like an Activity, each Fragment has its own layout that’s typically defined as an XML layout resource file (GUIs also can be created dynamically).
c. You can create an XML file describing the user preferences, then class Prefer-enceFragment can use that file to build an appropriate preferences GUI.
d. Fragments can be hosted by an Activity or they can execute independently.

4.3.3 Fragment Lifecycle Methods
Q1. Method onCreateView is called after onCreate to build and return a View con-taining the Fragment’s GUI. This method receives a(n) ________, which you’ll use to programmatically inflate a Fragment’s GUI from the components specified in a predefined XML layout.
a. Inflater
b. GUICreator
c. GUIInflater
d. LayoutInflater

4.3.4 Managing Fragments
Q1. A FragmentManager can use ________ to dynamically add, remove and transi-tion between Fragments.
a. Transactions
b. FragmentTransactions
c. FragmentTransitions
d. Transitions

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.

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

4.3.7 Resource Folders
Q1. Resource folder names that begin with anim contain XML files that define ________, which can change an object’s transparency, size, position and rotation over time.
a. property
b. tweened
c. view
d. drawable

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.

Q3. In Java, a property is typically implemented in a class as a(n) ________.
a. static method
b. instance variable with both set and get accessors
c. non-static method
d. enumeration

Q4. Which of the following statements is false?
a. You can use a color state list to define separate colors for when Buttons are ena-bled or disabled.
b. Resource folder names that begin with raw contain resource files (such as audio clips) that are read into an app as streams of bytes. You use such resources to play sounds.
c. Resource folder names that begin with xml contain XML files that do not fit into the other resource categories—often XML data files used by the app.
d. All of the above are true.

4.3.8 Supporting Different Screen Sizes and Resolutions
Q1. You can provide String resources for different languages and regions. Android uses resource folders with ________ to choose the appropriate images, based on a device’s pixel density, and the correct language strings, based on a device’s locale and region settings.
a. qualified names
b. disqualified names
c. unqualified names
d. None of the above.

4.3.9 Determining the Device Orientation
Q1. An object of class ________ contains public instance variable orientation containing either ORIENTATION_PORTRAIT or ORIENTATION_LANDSCAPE for the de-vice’s current orientation.
a. Settings
b. Configuration
c. Orientation
d. None of the above

4.3.10 Toasts for Displaying Messages
Q1. ________ are often used to display minor error messages or informational mes-sages that disappear after a short period of time.
a. Tweets
b. Tooltips
c. Toasts
d. None of the above

4.3.11 Using a Handler to Execute a Runnable in the Future
Q1. Handler- method ________ receives as arguments a Runnable to execute and a delay in milliseconds. After the delay has passed, the Handler’s Runnable executes in the same thread that created the Handler.
a. executeDelayed
b. runDelayed
c. handleDelayed
d. postDelayed

Q2. In what thread does a Handler’s Runnable execute?
a. the GUI thread
b. the thread that created the Handler
c. a new thread that the Handler creates
d. None of the above

4.3.12 Applying an Animation to a View
Q1. You specify the number of times an animation should repeat with Animation method ________.
a. setRepetitions
b. repetitions
c. setRepeatCount
d. repeatCount

4.3.13 Using ViewAnimationUtils to Create a Circular Reveal Animator
Q1. You can use the ViewAnimationUtils class to create a circular reveal Anima-tor object by calling the createCircularReveal method. The animation appears as a ——–________ circular window that displays part of a UI element.
a. rotating
b. shrinking
c. expanding
d. shrinking or expanding

4.3.14 Specifying Colors Based on a View’s State Via a Color State List
Q1. You could define a ________ for a Button’s background color that specifies different colors for the Button’s pressed, unpressed, enabled and disabled states.
a. color state list
b. color list
c. color group
d. color state group

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.
d. Each of the above statements is true.

4.3.16 Logging Exception Messages
Q1. Which of the next three statements is false?
a. When exceptions occur or when you want to track important aspects of your code’s execution, you can log messages for debugging purposes with Android’s built-in logging mechanism.
b. Android provides class Log (package android.util) with several static meth-ods that represent messages of varying detail.
c. Logged messages can be viewed in the bottom of the Android Device Monitor’s LogCat tab or with the Android logcat tool.
d. Each of the above statements is true.

4.3.17 Launching Another Activity Via an Explicit Intent
Q1. Android uses a technique known as ________ to communicate information be-tween activities within one app or activities in separate apps.
a. intent messaging
b. intent dispatching
c. intent broadcasting
d. None of the above

Q2. Each Activity declared in the AndroidManifest.xml file can specify ________ indicating actions the Activity is capable of handling.
a. intent extractors
b. activity filters
c. intent filters
d. None of the above

Q3. An Activity is launched by using a(n) ________ that indicates an action to be performed and the data on which to perform that action.
a. Action
b. IntendedAction
c. Launcher
d. Intent

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

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

4.3.18 Java Data Structures
Q1. You can use Collections method ________ to randomize the order of the el-ements in an ArrayList.
a. reorder
b. shuffle
c. srand
d. randomize

4.3.19 Java SE 7 Features
Q1. If the Java compiler can infer a generic object’s type from the context, you can replace with <> when creating the object. In this context, <> is referred to as the ________ operator.
a. type
b. less than–greater than
c. inference
d. diamond

Q2. Rather than declaring a resource, using it in a try block and closing it in a finally block, you can use the ________ statement to declare the resource in the try block’s parentheses and use the resource in the try block. The resource is implicitly closed when ________.
a.
b. try-with-resources
c.
d.

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.
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.

4.4 Creating the Project, Resource Files and Additional Classes

4.4.2 Blank Activity Template Layouts
Q1. Which of the following three statements is false?
a. The Blank Activity template is a backward-compatible app template (for Android 2.1 and higher) that uses features of the Android Design Support Library.
b. The Blank Activity template must be used with a Fragment.
c. When you choose to use the Fragment option, the IDE creates layouts named activity_main.xml, content_main.xml and fragment_main.xml.
d. Each of the above statements are false.

Q2. Which of the following statements is true?
a. The default activity_main.xml layout embeds (via an element in the XML) the GUI defined in content_main.xml.
b. The default activity_main.xml layout also contains a FloatingActionBut-ton—a round image button from the Android Design Support Library that has a higher elevation than the GUI’s other components, so it “floats” over the GUI.
c. Each app based on the Blank Activity template includes a FloatingActionBut-ton (which typically emphasizes an important action that the user can perform by touching the button) and other material design features.
d. All of the above statements are true.

Q3. When you choose the Blank Activity template’s Fragment option, this file con-tains only a ________ element that displays the MainActivityFragment’s GUI de-fined in fragment_main.xml.
a.
b.
c.
d. None of the above

4.4.5 strings.xml and Formatted String Resources
Q1. The Android design guidelines indicate that text displayed in your GUI should be brief, simple and friendly with the important words ________.
a. centered
b. last
c. in italics
d. first

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

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 scenarios (different locales, night and day colors, and so on).
a. color-choosing
b. value-choosing
c. locale-choosing
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

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

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

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

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

Q3. A ________ animation moves a View within its parent.
a. alpha
b. scale
c. rotate
d. translate

Q4. The ________ attribute specifies how long the animation lasts in milliseconds.
a. android:duration
b. android:length
c. android:playbackTime
d. android:time

Q5. By default, animations in an animation set are applied simultaneously (i.e., in parallel), but you can use the ________ attribute to specify the number of millisec-onds into the future at which an animation should begin. This can be used to se-quence the animations in a set.
a. android:startTime
b. android:offset
c. android:sequence
d. android:startOffset

4.5.1 activity_main.xml Layout for Devices in Portrait Orientation
Q1. According to the Android design guidelines, ________ dp is the recommended space between the edges of a device’s touchable screen area and the app’s content; however, many apps (such as games) use the full screen.
a. 1.6
b. 16
c. 160
d. 16.6

4.5.2 Designing fragment_main.xml Layout
Q1. It’s often easiest to select a particular GUI component in ________.
a. the design area
b. the Component Tree window
c. XML
d. None of the above

Q2. By default, the IDE set the layout’s Padding Left and Padding Right properties to a predefined dimension resource named @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

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

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

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

Q7. Setting a Button’s style property to @android:style/Widget.Material.Button.Colored causes the Button to take on a colored appearance, based on the colors of the app’s theme. The Buttons’ color will be the theme’s ________.
a. accent color
b. primary color
c. dark primary color
d. None of the above

4.6.3 Overridden Activity Method onCreate
Q1. When you install and launch an app for the first time, calling Prefer-enceManager method setDefaultValues sets the app’s default preferences—this creates and initializes the app’s ________ file using the default values that you spec-ified in preferences.xml.
a. Settings
b. Preferences
c. SharedPreferences
d. SharedSettings

Q2. Method getConfiguration returns a Configuration object (package an-droid.content.res) containing public instance variable ________, which speci-fies the device’s screen-size category.
a. screenSize
b. size
c. layout
d. screenLayout

4.6.4 Overridden Activity Method onStart
Q1. Which of the following statements is false?
a. When the app first executes, onCreate is called after onStart.
b. When the app is running in portrait orientation and the user opens the Set-tings-Activity, the MainActivity is stopped while the SettingsActivity is displayed. When the user returns to the MainActivity, onStart is called again.
c. To get a reference to the MainActivityFragment so we can call its methods, use inherited AppCompatActivity method getSupportFragmentManager to get the FragmentManager, then call its findFragmentById method.
d. Each of the above statements is true.

4.6.5 Overridden Activity Method onCreateOptionsMenu
Q1. Which of the following statements is false?
a. You must create methods onCreateOptionsMenu and onOptionsItemSelected when you use Android Studio’s Blank Activity template.
b. Activity’s Resources object (returned by inherited method getResources-) can obtain a Configuration object (returned by method getConfiguration) that represents the device’s current configuration.
c. Inherited Activity method getMenuInflater returns a MenuInflater on which you can call inflate with two arguments—the resource ID of the menu resource that populates the menu and the Menu object in which the menu items will be placed.
d. Returning true from onCreateOptionsMenu indicates that the menu should be displayed.

4.6.6 Overridden Activity Method onOptionsItemSelected
Q1. Method ________ is called when a menu item is selected.
a. onOptionSelected
b. onMenuItemSelected
c. onItemSelected
d. onOptionsItemSelected

4.6.7 Anonymous Inner Class That Implements OnSharedPreferenceChangeListener
Q1. Toast method ________ receives as arguments the Context on which the Toast is displayed, the message to display and the duration for which the Toast will be displayed. Toast method show displays the Toast.
a. makeToast
b. buildToast
c. makeText
d. buildText

4.7.3 Overridden Fragment Method onCreateView
Q1. Method inflate returns a reference to a ________ that contains the inflated GUI.
a. Layout
b. Inflator
c. View
d. RelativeLayout

Q2. You can use a(n) ________ object to delay the performance of an action.
a. DelayedAction
b. ActionHandler
c. TaskHandler
d. Handler

4.7.4 Method updateGuessRows
No questions.
4.7.5 Method updateRegions
No questions.
4.7.6 Method resetQuiz
Q1. IOExceptions are ________ exceptions (so you must catch or declare the ex-ception).
a. required
b. important
c. special
d. checked

Q2. Which of the following is true?
a. Log static method error is used to log error messages.
b. Log static method e is used to log error messages.
c. Log static method exception is used to log error messages.
d. None of the above.

4.7.9 Method animate
Q1. Which of the following is false?
a. Animator method createCircularReveal creates a circular reveal animation.
b. Animator method setDuration specifies the animation’s duration in millisec-onds.
c. Animator method start begins executing the animation.
d. Animator method addListener registers a listener for various animation events, such as when the animation ends.

4.7.10 Anonymous Inner Class That Implements OnClickListener
Q1. Implement interface ________ to respond to Button events. The method re-ceives the clicked Button as a parameter.
a. OnTouchListener
b. OnButtonClickListener
c. OnButtonTouchListener
d. OnClickListener

Q2. Which of the following statements is false?
a. You can set an AlertDialog’s title (which appears above the dialog’s message) with AlertDialog.Builder method setTitle.
b. According to the Android design guidelines for dialogs, most dialogs need titles.
c. A dialog should display a title for “a high-risk operation involving potential loss of data, connectivity, extra charges, and so on.”
d. Dialogs that display lists of options use the title to specify the dialog’s purpose.

4.9 SettingsActivityFragment Class
Q1. As the user interacts with the preferences GUI, the preferences are automatically stored into a ________ file on the device. If the file does not exist, it will be creat-ed; otherwise, it will be updated.
a. Preferences
b. SharedPreferences
c. Settings
d. Configuration

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.

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!