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 03


 

Download  file with the answers

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


chapter 3

Tip Calculator App

3.1 Introduction
Q1. You may configure your AVD (or device) to display the keyboard for better contrast in your screen captures.
a. black
b. shaded
c. dark
d. ebony

3.2 Test-Driving the Tip Calculator App
Q1. By default, the Seekbar allows you to select values from 0 to 100.
a. 1 to 100
b. 1 to 256
c. 0 to 100
d. 0 to 256

3.3 Technologies Overview
3.3.1 Class Activity
Q1. Android apps have four types of executable components—activities, services, content providers and .
a. broadcast receivers
b. broadcast transmitters
c. broadcasters
d. receivers

Q2. Which of the following statements is false?
a. An app can have many activities, and an Activity can manage multiple Frag-ments.
b. You interact with an Activity through views—GUI components that inherit from class View (package android.view).
c. Before Android 3.0, a separate Activity was typically associated with each screen of an app.
d. On a tablet, each Fragment typically occupies the entire screen and the Activity switches between the Fragments, based on user interactions.

3.3.2 Activity Lifecycle Methods
Q1. Throughout its life, an Activity can be in one of several states—active (i.e., running), or stopped.
a. halted
b. paused
c. ceased
d. discontinued

Q2. Activities transition between their states in response to various .
a. actions
b. steps
c. events
d. deeds

Q3. Which of the following statements is false?
a. An active Activity is visible on the screen and “has the focus”—that is, it’s in the foreground. You can interact with the Activity currently in the foreground.
b. A stopped activity is not visible on the screen—it’s in the background and is likely to be killed by the system when its memory is needed.
c. An Activity is stopped when another Activity enters the foreground and be-comes active. For example, when you answer a phone call, the phone app becomes active and the app you previously were using is stopped.
d. Each activity lifecycle method you override must call the subclass’s version; oth-erwise, an exception will occur.

3.3.3 AppCompat Library and Class AppCompatActivity
Q1. Google now introduces many new Android features via the Android Support Library—a set of libraries that enable you to .
a. use newer Android features in apps targeting current and past Android platforms
b. use new Android features only in the current Android platform version
c. use old Android features in new Android platforms
d. None of the above.

Q2. Android Studio’s app templates have been updated to use the li-brary, enabling the new apps you create to run on almost all Android devices, in-cluding ones with older Android versions.
a. Compatibility
b. AppCompat
c. SupportLibrary
d. None of the above.

3.3.4 Arranging Views with a GridLayout
Q1. Which of the following three statements is true?
a. You arrange a GUI’s views in layouts.
b. A GridLayout (package android-.widget) arranges views into cells in a rec-tangular grid.
c. Cells in a GridLayout can occupy multiple rows and columns, allowing for com-plex layouts.
d. All of the above statements are true.

3.3.5 Creating and Customizing the GUI with the Layout Editor and the Component Tree and Properties Windows
Q1. A(n) ________is a subclass of Text-View that can display text and accept text input from the user.
a. TextBox
b. EditText
c. TextField
d. EditInput

Q2. A represents an integer in the range 0–100 by default and allows the user to select a number in that range by moving its thumb.
a. GridLayout
b. EditText
c. SeekBar
d. None of the above

3.3.6 Formatting Numbers as Locale-Specific Currency and Percentage Strings
Q1. You’ll use class (package java.text) to create locale-specific cur-rency and percentage strings—an important part of internationalizing your apps.
a. LocaleFormat
b. StringFormat
c. InternationalFormat
d. NumberFormat

3.3.7 Implementing Interface TextWatcher for Handling EditText Text Changes
Q1.To respond to events when the user changes the text in an EditText, you’ll use an anonymous inner class to implement the interface (from package android-.text).
a. EditTextListener
b. TextListener
c. EditTextWatcher
d. TextWatcher

3.3.8 Implementing Interface OnSeekBarChangeListener for Handling SeekBar Thumb Position Changes
Q1. You’ll use an anonymous inner class to implement the interface (from package android.widget) to respond to the user moving the SeekBar’s thumb.
a. SeekBar.OnSeekBarChangeListener
b. SeekBar.ChangeListener
c. SeekBar.OnChangeListener
d. None of the above.

Q2. A SeekBar listeners’s method executes when the user moves the SeekBar’s thumb.
a. onThumbMoved
b. userMovedThumb
c. onProgressChanged
d. None of the above

3.3.9 Material Themes
Q1. Which of the following statements is false?
a. A theme gives an app a look-and-feel that’s consistent with Android.
b. Projects that you create for Android 5 and higher use themes that adhere to Google’s material- design guidelines.
c. There are several predefined material design themes: The “light” theme has a white app bar, a white app background and text that is black or shades of dark gray.
d. When designing a GUI, you must choose from the predefined themes.

Q2. Many of today’s Android phones use AMOLED displays. On such displays, a black pixel is turned off and does not consume power. Apps that use mostly black themes can reduce power consumption by approximately .
a. 10%
b. 70%
c. 40%
d. 90%

3.3.10 Material Design: Elevation and Shadows
Q1. When you set a view’s property, Android automatically casts a shadow for that view.
a. shadow
b. elevation
c. altitude
d. levitation

3.3.11 Material Design: Colors
Q1. Which of the following statements is false?
a. If you need to customize theme colors, Google’s material design guidelines for color recommend that you choose a color palette consisting of a primary col-or—with no more than five hues (shades)—and an accent color.
b. The primary colors typically are used to color the status bar and the app bar at the top of the screen and also can be used in your GUI.
c. The accent color is used to tint various views in your GUI, such as SeekBars, CheckBoxes and RadioButtons.
d. Once you choose a palette, you can use Android Studio’s Theme Editor to modi-fy a theme’s colors.

3.3.12 AndroidManifest.xml
Q1: Which of following statements is false?
a. You create the AndroidManifest.xml file when you create a new app project.
b. Settings you specify in the Create New Project dialog include the app’s name, package name, Activity name(s) and more.
c. You can edit the AndroidManifest.xml file’s XML to add a new setting that forces the soft keyboard to be displayed when the app begins executing.
d. You’ll also specify that the app supports only portrait orientation—that is, the device’s longer dimension is vertical.

3.4 Building the GUI
3.4.1 GridLayout Introduction
Q1. Which of the following statements is false?
a. A GridLayout (package android.widget) arranges views into rows and col-umns, each indexed from 0 like the elements of an array.
b. Each cell of a GridLayout can be empty or can hold one or more views, includ-ing layouts containing other views.
c. A GridLayout row’s height is determined by the row’s tallest view–similarly, a column’s width is defined by the column’s widest view.
d. A GridLayout’s views can span multiple rows and/or columns.

3.4.3 Changing to a GridLayout
Q1. The default layout for an Empty Activity is a .
a. GridLayout
b. LinearLayout
c. RelativeLayout
d. None of the above.

Q2. Which of the next three statements is false?
a. By default, there are no margins—spacing that separates views—around a GridLayout’s cells.
b. The material design guidelines recommend 18dp minimum spacing between views.
c. GridLayout can enforce the recommended spacing between views. With the GridLayout selected in the Component Tree, in the Properties window, check the GridLayout’s useDefaultMargins property (which sets it to true) to use the recommended margins around the layout’s cells.
d. All of the above statements are true.

3.4.4 Adding the TextViews, EditText and SeekBar
Q1: Each time you drop a view onto the GridLayout in the Component Tree win-dow, the view is placed in the layout’s next open cell, unless you specify otherwise by .
a. setting the view’s layout:row property
b. setting the view’s layout:column property
c. setting both the view’s layout:row and layout:column properties
d. None of the above.

Q2. When the virtual keyboard is displayed, the device’s back button changes to a down button that enables you to .
a. scroll down the screen
b. dismiss the app’s current activity and return to the prior one.
c. hide the app
d. dismiss the keyboard

3.4.5 Customizing the Views
Q1. Why would you set the digits property of an EditText to 0123456789?
a. To allow only characters other than the digits 0–9 to be entered.
b. To allow only the string of digits 0123456789 to be entered.
c. To allow only digits to be entered (in any order and combination).
d. None of the above.

Q2. By default, a SeekBar’s range is 0 to 100 and its current value is indicated by its property.
a. progress
b. value
c. thumb
d. None of the above.

3.5 Default Theme and Customizing Theme Colors
Q1. Each app has a theme that defines the default look-and-feel of the standard views you use. The theme is specified in the app’s AndroidManifest.xml file. You can customize aspects of an app’s theme, such those that define an app’s color scheme, by defining style resources in the file located in the app’s res/values folder.
a. themes.xml
b. styles.xml
c. colors.xml
d. None of the above.

3.5.1 parent Themes
Q1. Which of the following satements is false?
a. The style.xml resource file contains a style with the name “AppTheme” that’s referenced from the app’s AndroidManifest.xml file to specify the app’s theme.
b. A parent theme is similar to a subclass in Java—the new style inherits its par-ent theme’s attributes and their default values.
c. Just as in a Java subclass, a style can override parent theme attributes with values customized for specific apps.
d. By default, Android Studio sets the parent theme to
Theme.AppCompat.Light.DarkActionBar
one of several predefined themes from the AppCompat library—apps that use this theme have a light background, except for the dark app bar at the top of the app.

3.5.2 Customizing Theme Colors
Q1. You can use the new Android Studio to change the app’s primary, dark primary and accent colors.
a. Color Editor
b. Design Editor
c. Layout Editor
d. Theme Editor

3.5.3 Common View Property Values as Styles
Q1. Which of the next three statements is false?
a. style resources can define common property values that should be applied to multiple views.
b. You apply a style resource to a given view by setting its style property.
c. Any subsequent changes you make to a style are automatically applied to all views using the style.
d. All of the above statements are true.

3.6.1 package and import Statements
Q1. Which of the following statements is false?
a. Class Bundle of package android.os stores key–value pairs of infor-mation—typically representing an app’s state or data that needs to be passed between activities.
b. When another app is about to appear on the screen—e.g., when the user receives a phone call or launches another app—Android gives the currently executing app the opportunity to save its state in a Bundle. The Android runtime might subsequently kill the app—e.g., to reclaim its memory.
c. When the app returns to the screen, the Android runtime passes the Bundle of the previously saved state to Activity method onStart.
d. We can use Bundles to pass data between activities.

Q2. Which of the following statements is false?
a. App-Activity is an indirect subclass of Activity that supports using newer An-droid features apps running on current and older Android platforms.
b. You implement interface TextWatcher of package android.text to respond to events when the user changes the text in an EditText.
c. You implement interface SeekBar.OnSeekBarChangeListener of package an-droid.widget to respond to the user moving the SeekBar’s thumb.
d. Class NumberFormat of package java.text provides numeric formatting capabil-ities, such as locale-specific currency and percentage formats.

3.6.3 Class Variables and Instance Variables
Q1. For precise monetary calculations, use class (package ja-va.math)—rather than type double—to represent the monetary amounts and per-form calculations.
a. MonetaryAmount
b. Cash
c. BigDecimal
d. None of the above.

3.6.4 Overriding Activity Method onCreate
Q1. Method onCreate typically initializes the Activity’s instance variables and views. This method should be as simple as possible so that the app loads quickly. If the app takes longer than five seconds to load, the operating system will display a(n) dialog, giving the user the option to forcibly terminate the app.
a. PNR (Program Not Responding)
b. ANR (Application Not Responding)
c. ANR (Android Not Responding)
d. None of the above.

Q2. Which of the following actions does not change the device’s configuration?
a. rotating the device
b. connecting to a Bluetooth keyboard
c. sliding out a hard keyboard
d. All of the above change the device’s configuration.

Q3. Which of the following statements about class R’s nested classes is false?
a. class R.drawable contains constants for any drawable items, such as images, that you put in the various drawable folders in your app’s res folder.
b. class R.id contains constants for the views in your HTML layout files.
c. class R.layout contains constants that represent each layout file in your project (such as, activity_main.xml).
d. class R.string contains constants for each String in the strings.xml file.

Q4. The call to setContentView receives the R.layout constant indicating the XML file that represents a GUI—e.g., R.layout.activit_main represents the ac-tivity_main.xml file. Method setContentView uses this constant to load the cor-responding XML document, which Android parses and converts into the app’s GUI. This process is known as the GUI.
a. creating
b. inflating
c. fabricating
d. building

Q5. Class Activity’s method takes an int constant representing a spe-cific view’s ID and returns a reference to the view.
a. findId
b. findView
c. findViewById
d. None of the above.

3.6.6 Anonymous Inner Class That Implements Interface OnSeekBarChangeListener
Q1. Method is called whenever the SeekBar’s thumb position changes.
a. onProgressChanged
b. onSeekBarChanged
c. onThumbPositionChanged
d. onValueChanged

Q2. Java requires that you override every method in an that you im-plement.
a. struct
b. class
c. interface
d. enumeration

3.6.7 Anonymous Inner Class That Implements Interface TextWatcher
Q1. The method is called whenever the text in the amount-EditText is modified.
a. onNewValue
b. onEditTextChanged
c. watchedTextChanged
d. onTextChanged

3.7.1 manifest Element
Q1. For apps you submit to the Google Play store, the is used as the app’s unique identifier.
a. app name
b. class name
c. package name
d. folder name

3.7.2 application Element
Q1. The manifest element’s nested element specifies attributes of the application.
a. activity
b. application
c. app
d. None of the above.

3.7.3 activity Element
Q1. Which of the following is false regarding the manifest’s activity element?
a. android:name is the app’s name.
b. android:label is the Activity’s name.
c. android:screenOrientation specifies the Activity’s orientation.
d. android:windowSoftInputMode can be used to specify that the soft keypad should be displayed immediately when the app executes and should reappear each time the user returns to the app.

3.7.4 intent-filter Element
Q1. Which of the following statements about Intents is false?
a. Intents are Android’s mechanism for communicating between executable com-ponents—such as activities, background services and the operating system.
b. You state your intent, then Android uses intent messaging to coordinate the exe-cutable components to accomplish what you intend to do.
c. This tight coupling makes it easy to mix and match parts of different applications.
d. You tell Android what you want to accomplish, then let Android find the in-stalled applications with activities that can handle the task.

Q2. In the manifest, the activity element’s nested element determines which Intent types can launch an Activity-.
a. intent
b. filter
c. intent–filter
d. filter-intents

Q3. Which of the following statements is false?
a. If an Intent matches only one Activity’s intent-filter, Android executes that Activity.
b. If there are multiple matches, Android presents a list from which the user can choose an app, then executes the appropriate Activity in that app.
c. An Intent often contains data the Activity can use to perform its task.
d. The intent-filter element optionally can contain one or more action ele-ments.

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!