Android How To Program 3rd Edition By Deitel & Deitel – Test Bank

$25.00

Category:

Description

INSTANT DOWNLOAD WITH ANSWERS
Android How To Program 3rd Edition By Deitel & Deitel – Test Bank

Chapter 2—Welcome App

  • Introduction

Q1. Which of the following statements is false?

  1. Android Studio’s layout editor enables you to build GUIs using drag-and-drop techniques.
  2. You can edit the GUI’s XML directly.
  3. In portrait orientation the device’s width is greater than its height.
  4. Android’s Explore by Touch enables users to touch items on the screen and hear TalkBack speak the corresponding descriptive text.

Answer: c. Actually, in portrait orientation the device’s height is greater than its width.

 

Q2. You can ________ an app so that you can provide localized strings in different languages.

  1. translate.
  2. convert.
  3. transcribe.
  4. internationalize.

Answer: d. internationalize.

  • Technologies Overview

No questions.

  • Android Studio

No questions.

  • LinearLayout, TextView and ImageView

Q1. ________ are views that contain and arrange other views.

  1. Layouts.
  2. TextViews.
  3. ImageViews.
  4. None of the above.

Answer: a. Layouts

 

Q2. Which of the following statements is false?

  1. You can use a vertical LinearLayout to arrange an app’s text and image with each occupying half the LinearLayout’s vertical space.
  2. A LinearLayout also can arrange views horizontally.
  3. The default GUI created by Android Studio already contains an ImageView.
  4. You can use the layout editor’s Palette of views to drag and drop an ImageView onto a GUI, then configure its properties.

Answer: c. The default GUI created by Android Studio already contains an ImageView. Actually, the default GUI created by Android Studio already contains a TextView.

 

Q3. Which of the following statements is true?

  1. Extensible Markup Language (XML) is a natural way to express GUIs.
  2. XML is human- and computer-readable text and, in the context of Android, helps you specify the layouts and components to use, as well as their attributes, such as size, position, color, text size, margins and padding.

c.You use XML files to store app resources, such as strings, numbers and colors.

  1. All of the above are true.

Answer: d. All of the above are true.

  • App Resources

Q1. (True/False) It’s considered good practice to define all strings, numeric values and other values in XML resource- files that are placed in the subfolders of a project’s resources folder.

Answer: False. Actually, it’s the res folder.

 

Q2. (True/False) For a TextView font color, you should typically create a color resource using a color selected from Google’s Material Design color palette.

Answer: True.

  • Accessibility

Q1. Which of the first three statements below is false?

  1. Android provides accessibility features to help people with certain disabilities use their devices.
  2. People with visual impairments can use Android’s TalkBack to allow a device to speak screen text or text that you provide to help them understand the purpose and contents of a view.
  3. Android’s Explore by Touch enables the user to touch the screen to hear TalkBack speak what’s on the screen near the touch.
  4. All of the above are true.

Answer. d. All of the above are true.

  • Internationalization

Q1. Which of the following statements is true?

  1. To reach the most users with your apps, you should consider customizing them for various locales and spoken languages.
  2. Configuring your app so that it can be customized for various locales is known as localization.
  3. Customizing your app for a specific locale is known as internationalization.
  4. All of the above statements are false.

Answer. a. To reach the most users with your apps, you should consider customizing them for various locales and spoken languages.

  • Creating an App

No questions.

  • Launching Android Studio

No questions.

  • Creating a New Project

Q1. A ________ is a group of related files, such as code files, resource files and images that make up an app.

  1. folder
  2. directory
  3. solution
  4. project

Answer: d. project.

  • Create New Project Dialog

Q1. Which of the following statements is false?

  1. The package name normally begins with your company’s or institution’s Company Domain in reverse. This is followed by a dot (.) and the app’s name in all lowercase letters with any spaces removed.
  2. By convention, package names use only lowercase letters.
  3. The IDE sets the package name using the text you enter for Company Name and Company Domain.
  4. By default, Android Studio places new project folders in the subfolder AndroidStudioProjects in your user account directory.

Answer: c. The IDE sets the package name using the text you enter for Company Name and Company Domain. Actually, the IDE sets the package name using the text you enter for Application Name and Company Domain.

  • Target Android Devices Step

Q1. Which of the following statements is false?

  1. The Minimum SDK is the minimum Android API level that’s required to run your app. This allows your app to execute on devices supporting that API level and higher.
  2. Lower Minimum SDK values enable your app to run on more devices.
  3. Generally you should target the highest API level on which your app can run.
  4. You must disable newer features that are not available on older platforms when your app is installed on those platforms.

Answer: c. Generally you should target the highest API level on which your app can run. Actually, generally you should target the lowest API level on which your app can run, so your app can run on the largest possible number of devices.

  • Add an Activity to Mobile Step

Q1. Which type of app template is described by: “Used for a single-screen app (similar to Blank Activity) that occupies the entire screen, but can toggle visibility of the device’s status bar and the app’s app bar.”

  1. Empty Activity.
  2. Fullscreen Activity.
  3. Master/Detail Flow.
  4. None of the above.

Answer: b. Fullscreen Activity.

  • Customize the Activity Step

No questions.

  • Android Studio Window

No questions.

  • Project Window

Q1. The ________ window provides access to all of the project’s files.

  1. Organizer
  2. Explorer
  3. Project
  4. None of the above.

Answer: c. Project

 

Q2. (True/False) You can have only one project open in the IDE at once.

Answer: False. Actually, you can have many projects open in the IDE at once—each in its own window.

 

Q3. The ________ folder contains the files you’ll edit to create your apps’ GUIs and logic.

  1. java
  2. res
  3. app
  4. manifests

Answer: c. app

  • Editor Windows

Q1. The code editors for Java and XML help you write code quickly and correctly via ________—as you type, you can press Enter (or Return) to automatically finish a Java code element or an XML element name, attribute name or value that is currently highlighted in the code-completion window.

  1. code-for-me
  2. code-completion
  3. automated coding
  4. None of the above.

Answer: b. code-completion

  • Component Tree Window

Q1. When the layout editor is open in Design view, the ________ appears at the right side of the IDE. This window shows the layouts and views (GUI components) that comprise the GUI and their parent-child relationships—for example, a layout (the parent) might contain many nested views (the children), including other layouts.

  1. Project window
  2. Properties window
  3. Palette
  4. Component Tree

Answer: d. Component Tree

  • App Resource Files

Q1. Layout files like activity_main.xml are app ________ and are stored in subfolders of the project’s res folder.

  1. code
  2. descriptions
  3. resources
  4. None of the above.

Answer: Actually, it’s the res folder.

  • Layout Editor

No questions.

  • Default GUI

Q1. With a ________ you can, for example, specify that one view should appear below another and be centered horizontally within this layout.

  1. LinearLayout
  2. CenteredLayout
  3. RelativeLayout
  4. None of the above.

Answer: c. RelativeLayout

  • XML for the Default GUI

Q1. In a layout XML file, attribute values that begin with @, such as

@dimen/activity_vertical_margin are ________ with values defined in other files.

  1. resources
  2. variables
  3. dimentions
  4. None of the above.

Answer: a. resources

  • Building the App’s GUI with the Layout Editor

Q1. Android Studio allows you to build your GUI by dragging and dropping views—such as Text-Views, Image-Views and Buttons—onto the ________.

  1. GUI designer
  2. layout designer
  3. GUI editor
  4. layout editor

Answer: d. layout editor

  • Adding an Image to the Project

Q1. Which of the following statements is false?

  1. Android devices have various screen sizes, resolutions and pixel densities (that is, dots per inch or DPI), so you typically provide images in various resolutions that the operating system chooses based on a device’s pixel density. These are placed in drawable folders (in a project’s res folder) that store images with different pixel densities.
  2. Android Studio displays only one drawable folder containing the app’s drawable resources, even if your project contains resources for multiple densities.
  3. If Android cannot find an image in the drawable folder that most closely matches the device’s pixel density, Android will display nothing for that image.
  4. Low-resolution images do not scale well. For images to render nicely, a high-pixel-density device needs higher-resolution images than a low-pixel-density device.

Answer: c. If Android cannot find an image in the drawable folder that most closely matches the device’s pixel density, Android will display nothing for that image. Actually, if Android cannot find an image in the drawable folder that most closely matches the device’s pixel density, Android will scale the version from another drawable folder up or down as necessary.

  • Adding an App Icon

Q1. When your app is installed on a device, its icon and name appear with all other installed apps in the ________.

  1. finder
  2. explorer
  3. launcher
  4. None of the above.

Answer: c. launcher

 

Q2. Which of the first three statements about uploading apps to Google Play is false?

  1. You can upload multiple versions of the app for various device- sizes and screen resolutions.
  2. All images in the mipmap folders are uploaded with every version of your app.
  3. You can remove extra drawable folders for specific pixel densities from a given app version to minimize the total installation size for a particular device.
  4. All of the above are true.

Answer: d. All of the above are true.

  • Changing RelativeLayout to a LinearLayout

Q1. When you open a layout XML file, the layout’s design appears in the layout editor and the layout’s views and their hierarchical relationships appear in the ________ window.

  1. Outline
  2. Tree
  3. Layout Editor
  4. Component Tree

Answer: d. Component Tree

  • Changing the LinearLayout’s id and orientation

Q1. Which of the following statements is false?

  1. When a GUI is displayed in the layout editor, you can use the Properties window below the Component Tree to configure the selected view’s properties.
  2. You also can edit a view’s most commonly used properties by double clicking the view in the canvas. The layout editor then displays a small dialog in which you can set the view’s id property and other properties that depend on the specific view:
  3. For a LinearLayout, you can set the orientation to specify whether the layout’s children are arranged in horizontal or vertical orientation.
  4. For an ImageView, you can set the src (source) of the image to display.

Answer: c. For a LinearLayout, you can set the orientation to specify whether the layout’s children are arranged in landscape or portrait orientation. Actually, for a LinearLayout, you can set the orientation to specify whether the layout’s children are arranged in horizontal or vertical orientation.

  • Configuring the TextView’s id and text Properties

Q1. Which of the following statements is false?

  1. It’s considered good practice to place strings, string arrays, images, colors, font sizes, dimensions and other app resources in XML files within the subfolders of the project’s res folder, so these resources can be managed separately from your app’s Java code.
  2. If you externalize color values, it becomes more difficult to update all components that use the same color.
  3. If you wish to localize your app in several languages, storing the strings separately from the app’s code allows you to change them easily.
  4. In your project’s res folder, the subfolder values contains a strings.xml file that’s used to store the app’s default language strings—English for our apps.

Answer: b. If you externalize color values, it becomes more difficult to update all components that use the same color. Actually, if you externalize color values, all components that use the same color can be updated to a new color simply by changing the color value in a central resource file.

  • Configuring the TextView’s textSize Property—Scaled Pixels and Density-Independent Pixels

Q1. Which of the following statements is false?

  1. You should use density-independent pixels for font sizes, and scale-independent pixels for dimensions of views and other screen elements.
  2. Defining your GUIs with density-independent pixels enables the Android platform to scale the GUI, based on the pixel density of a given device’s screen.
  3. One density-independent pixel is equivalent to one pixel on a 160-dpi screen.
  4. On a 240-dpi screen, each density-independent pixel will be scaled by a factor of 240/160 (i.e., 1.5). So, a component that’s 100 density-independent pixels wide will be scaled to 150 actual pixels wide.

Answer: a. You should use density-independent pixels for font sizes, and scale-independent pixels for dimensions of views and other screen elements. Actually, you should use density-independent pixels for dimensions of views and other screen elements, and scale-independent pixels for font sizes.

  • Setting the TextView’s textColor Property

Q1. Which of the following statements is false?

  1. When you need custom colors in your apps, Google’s Material Design guidelines recommend using colors from the Material Design color palette.
  2. Colors are specified as RGB (red-green-blue) or ARGB (alpha-red-green-blue) values.
  3. An RGB value consists of integer values in the range 1–100 that define the amounts of red, green and blue in the color, respectively.
  4. Custom colors are defined in hexadecimal format, so the RGB components are values in the range 00 (the hexadecimal value for 0) to FF (the hexadecimal value for 255).

Answer: c. An RGB value consists of integer values in the range 1–100 that define the amounts of red, green and blue in the color, respectively. Actually, an RGB value consists of integer values in the range 0–255 that define the amounts of red, green and blue in the color, respectively.

  • Setting the TextView’s gravity Property

Q1. To center the text in the TextView if it wraps to multiple lines, you can set its ________ property to center.

  1. alignment
  2. weight
  3. gravity
  4. positioning

Answer: c. gravity

  • Setting the TextView’s layout:gravity Property

No questions.

  • Setting the TextView’s layout:weight Property

Q1. A LinearLayout can proportionally size its children based on their ________, which specify the view’s relative size with respect to the layout’s other views.

  1. layout:widths
  2. layout:heights
  3. layout:gravity
  4. layout:weights

Answer: d. layout:weights

 

Q2. Android ________ checks your project for common errors, and makes suggestions for better security-, enhanced performance, improved accessibility, internationalization- and more. Some checks occur as you build your apps and write code.

  1. Cleanser.
  2. Lint.
  3. Error Checker.
  4. None of the above.

Answer: b. Lint

  • Adding an ImageView to Display the Image

Q1. Which of the following statements about adding an ImageView to the GUI by dragging it from the Palette’s Widgets section onto the canvas is false?

  1. When you drag a view onto the canvas, the layout editor displays orange guide lines, green guide lines and a tooltip.
  2. The orange guide lines show the bounds of each existing view in the layout.
  3. The green guide lines indicate where the new view will be placed with respect to the existing views—by default, new views are added at the top of a vertical LinearLayout, unless you position the mouse below the orange box that bounds the layout’s bottommost view.
  4. The tooltip displays how the view will be configured if you drop it at the current position.

Answer: c. The green guide lines indicate where the new view will be placed with respect to the existing views—by default, new views are added at the top of a vertical LinearLayout, unless you position the mouse below the orange box that bounds the layout’s bottommost view. Actually, by default, new views are added at the bottom of a vertical LinearLayout, unless you position the mouse above the orange box that bounds the layout’s topmost view.

  • Previewing the Design

No questions.

  • Running the Welcome App

No questions.

  • Making Your App Accessible

Q1. Which of the following statements is false?

  1. For people with visual disabilities, Android’s TalkBack can speak screen text or text that you provide (when designing your GUI or programmatically) to help the user understand the purpose of a view.
  2. Android also provides Explore by Touch, which enables the user to hear TalkBack speak what’s on the screen where the user touches.
  3. Most standard Android views support accessibility.
  4. You enable TalkBack in the Settings app under Accessibility. From that page, you also can enable other Android accessibility features such as a larger default text size and the ability to use gestures that magnify areas of the screen.

Answer: c. Most standard Android views support accessibility. Actually, all standard Android views support accessibility.

 

Q2. For an ImageView there is no text for TalkBack to speak unless you provide it. It’s considered good practice in Android to ensure that every view can be used with TalkBack by providing text for the ________ property of any view that does not display text.

  1. talkBack
  2. description
  3. hint
  4. contentDescription

Answer: d. contentDescription

  • Internationalizing Your App

Q1. Which of the following statements is false?

  1. To reach the largest possible audience, you should consider designing your apps so that they can be customized for various locales and spoken languages.
  2. You might also choose to use different colors, graphics and sounds based on the locale.
  3. When the user launches the app, Android automatically finds and loads the resources that match the device’s locale settings.
  4. Designing an app so it can be customized is known as localization. Customizing an app’s resources for each locale is known as internationalization.

Answer: d. Designing an app so it can be customized is known as localization. Customizing an app’s resources for each locale is known as internationalization. Actually, designing an app so it can be customized is known as internationalization. Customizing an app’s resources for each locale is known as localization.

  • Localization

No questions.

  • Naming the Folders for Localized Resources

Q1. Android uses a special folder-naming scheme to automatically choose the correct localized resources. You can name these folders with region information—values-en-rUS would contain a strings.xml file for United States English and ________ would contain a strings.xml file for United Kingdom English.

  1. values-en-rUK
  2. values-en-rEN
  3. values-en-rGB
  4. values-en-rBR

Answer: c. values-en-rGB

 

Q2. If localized resources are not provided for a given locale, Android uses the app’s default resources—that is, those in the res folder’s ________ subfolder.

  1. defaults
  2. english
  3. values
  4. strings

Answer: c. values

  • Adding String Translations to the App’s Project

Q1. Android Studio provides a ________ for quickly and easily adding translations for existing strings in your app.

  1. Translator
  2. Translations Editor
  3. Converter
  4. None of the above.

Answer: b. Translations Editor

  • Localizing Strings

No questions.

  • Testing the App in Spanish on an AVD

Q1. If Android cannot find a localized version of a string resource, it uses the default version in the ________ file.

  1. res/values/defaults.xml
  2. res/values/english.xml
  3. res/values/values.xml
  4. res/values/strings.xml

Answer: d. res/values/strings.xml

  • Testing the App in Spanish on a Device

No questions.

  • TalkBack and Localization

Q1. When you first switch your device to French and enable TalkBack, Android will automatically download the ________ engine.

  1. English-to-French.
  2. Translations.
  3. French text-to-speech.
  4. French Transalation.

Answer: c. French text-to-speech.

  • Localization Checklist

No questions.

  • Professional Translation

No questions.

 

Address Book App

  • Introduction

No questions

  • Test-Driving the Address Book App

No questions

  • Technologies Overview
  • Displaying Fragments with FragmentTransactions
  1. Which of the following statements is false?
  2. You can declare each Fragment in an Activity’s layout or, for a DialogFragment, call its show method to create it.
  3. An app can use multiple activities to host an app’s Fragments on a phone device.
  4. You can use only one Activity to host all of an app’s Fragments.
  5. On a phone-sized device, you’ll typically display several Fragments at a time.

Ans: d. On a phone-sized device, you’ll typically display several Fragments at a time. [Actually, on a phone-sized device, you’ll typically display one Fragment at a time.]

 

  1. You’ll use Android’s ________—a data structure that stores Fragments in last-in-first-out (LIFO) order-—to provide automatic support for the Android system bar’s back button and to allow the app to remove Fragments in the reverse order from which they were added.

Ans: Fragment back stack

 

  • Communicating Data Between a Fragment and a Host Activity
  1. (True/False) To communicate data between Fragments and a host Activity or the Activity’s other Fragments, it’s considered best practice to do so through the root Fragment.

Ans: False. Actually, it’s considered best practice to do so through the host Activity—this makes the Fragments more reusable, because they do not refer to one another directly.

 

  1. Typically, each Fragment defines an interface of ________ that are implemented in the host Activity.

Ans: callback methods

  • Method onSaveInstanceState
  1. Method ________ is called by the system when the configuration of the device changes during the app’s execution—for example, when the user rotates the device or slides out a keyboard on a device with a hard keyboard. This method can be used to save state information that you’d like to restore when the app’s onCreate method is called as part of the configuration change.

Ans:  onSaveInstanceState

 

  1. (True/False) When an app is simply placed into the background, perhaps so the user can answer a phone call or when the user starts another app, the app must save the contents of its GUI components for when the app is brought back to the foreground (provided that the system does not kill the app).

Ans: False. Actually, when an app is simply placed into the background, perhaps so the user can answer a phone call or when the user starts another app, the app’s GUI components will automatically save their contents for when the app is brought back to the foreground (provided that the system does not kill the app).

  • Defining Styles and Applying Them to GUI Components
  1. (True/False) You can define common GUI component attribute–value pairs as style resources. You can then apply the styles to all components that share those values by using the style attribute. Any subsequent changes you make to a style are automatically applied to all GUI components.

Ans: False. Actually, any subsequent changes you make to a style are automatically applied to all GUI components that use the style.

  • Specifying a Background for a TextView
  1. (True/False) By default TextViews do not have a border.

Ans: True.

  • Extending Class ListFragment to Create a Fragment That Contains a ListView
  1. (True/False) When a Fragment’s primary task is to display a scrollable list of items, you can extend class ListFragment. A ListFragment uses a ListView as its default layout.

Ans: True.

 

  1. (True/False) You can use a CursorAdapter (package android-.widget) to display the results of a database query in a ListView.

Ans: True.

  • Manipulating a SQLite Database
  1. SQLite is one of the world’s most widely deployed database engines. Database queries are performed with Structured Query Language (SQL) and query results are managed via a ________ (package android-.database).

Ans: Cursor

  • Performing Database Operations Outside the GUI Thread with AsyncTasks
  1. (True/False) You should perform long-running operations or operations that block execution until they complete (e.g., file and database access) in the GUI thread.

Ans: False. Actually, you should perform long-running operations or operations that block execution until they complete (e.g., file and database access) outside the GUI thread. This helps maintain application responsiveness and avoid Activity Not Responding (ANR) dialogs that appear when Android thinks the GUI is not responsive.

 

  1. When we need a database operation’s results in the GUI thread, we’ll use a subclass of ________ (package android.os) to perform the operation in one thread and receive the results in the GUI thread.

Ans: AsyncTask

  • Building the GUI and Resource Files
  • Creating the Project

No questions

  • Creating the App’s Classes

No questions

 

  • xml
  1. Why would you double click strings.xml in the res/values folder?

Ans: To display the resource editor for creating String resources.

 

  • xml
  1. (True/False) Like other resources, style resources are placed in the app’s res/values folder. When you create a project, the IDE creates a styles.xml file containing predefined styles. Each new style you create specifies a name that’s used to apply that style to GUI components and one or more items specifying property values to apply.

Ans: True.

 

  • xml
  1. (True/False) You must define Drawables in the project’s drawable folders for all device sizes and resolutions to be used with your app.

Ans: False. If a Drawable is defined in only one of the project’s drawable folders, Android will use that Drawable on all device sizes and resolutions.

  • MainActivity’s Layout: xml

No questions

 

  • DetailsFragment’s Layout: xml
  1. A ________ is a ViewGroup that can contain other Views (like a layout) and that lets users scroll through content too large to display on the screen.

Ans: ScrollView

 

  • AddEditFragment’s Layout: xml
  1. Each EditText specifies the Input Type and IME Options properties. For devices that display a soft keyboard, the Input Type specifies ________ when the user touches the corresponding EditText.

Ans: which keyboard to display

 

  1. Which of the following EditTexts’s Input Type property values might be used to ensure that state abbreviations are displayed in capital letters?
  2. textPersonName|textCapWords
  3. textPostalAddress|textCapWords
  4. textPostalAddress|textCapCharacters
  5. number

Ans: c. textPostalAddress|textCapCharacters

  • Defining the Fragments’ Menus
  1. (True/False) Each menu item’s Order in category values determines the order in which the menu items appear on the action bar.

Ans: True.

  • MainActivity Class
  1. (True/False) Class MainActivity manages the app’s fragments and coordinates the interactions between them. On phones, MainActivity displays one master Fragment and one detail Fragment at a time.

Ans: False. On phones, MainActivity displays one Fragment at a time.

 

  1. (True/False) You can configure a Fragment to be retained across configuration changes, such as when the user rotates the device.

Ans: True.

 

  1. If the resource ID ________ exists in MainActivity’s layout, then the app is running on a phone.

Ans: R.id.fragmentContainer

 

  1. Call the FragmentManager’s ________ method to remove the top Fragment on the back stack.

Ans: popBackStack

 

  1. You can pass arguments to a Fragment by placing them in a ________ of key–value pairs.

Ans: Bundle

 

  1. Call FragmentTransaction method ________ to push a Fragment onto the back stack. This allows the user to touch the back button to pop the Fragment from the back stack and allows MainActivity to programmatically pop the Fragment from the back stack.

Ans: addToBackStack

 

  • ContactListFragment Class
  1. You call Fragment method setRetainInstance with the argument true to indicate that a Fragment should be ________.

Ans: retained rather than recreated when the host Activity is re-created on a configuration change (e.g., when the user rotates the device)

 

  1. You call ListView method ________ to indicate that only one item can be selected at a time.

Ans: setChoiceMode

 

  1. Which of the following statements is false?
  2. To display the Cursor’s results in a ListView we create a new CursorAdapter object which exposes the Cursor’s data in a manner that can be used by a ListView.
  3. SimpleCursorAdapter is a subclass of CursorAdapter that’s designed to simplify mapping Cursor columns directly to TextViews or ImagesViews defined in your XML layouts.
  4. You must use standard layout resources for ListView items.
  5. You call inherited ListActivity method setListAdapter to bind a ListView to a CursorAdapter, so that the ListView can display the data.

Ans: c. You must use standard layout resources for ListView items. [Actually, you can create your own layout resources for ListView items.]

 

  1. (True/False) Each AsyncTask can be executed many times.

Ans: False. Each AsyncTask can be executed only once. You must create a new instance to execute an AsyncTask again.

 

  1. (True/False) When you call the AsyncTask’s execute method, doInBackground performs the task in the GUI thread.

Ans: False. Actually, doInBackground performs the task in a separate thread.

 

  1. (True/False) Fragment lifecycle method onStop is called after onPause when the Fragment is no longer visible to the user.

Ans: True.

 

  1. (True/False)You call CursorAdapter method changeCursor with the argument true to remove the Cursor from the CursorAdapter.

Ans: False. Actually, you call CursorAdapter method changeCursor with the argument null to remove the Cursor from the CursorAdapter.

  • AddEditFragment Class
  1. Call Fragment method getArguments to get the ________ of arguments (if any).

Ans: Bundle

  • DetailsFragment Class
  1. (True/False) Fragment method onSaveInstanceState executes when the configuration of the device changes during the app’s execution—for example, when the user rotates the device or slides out a keyboard on a device with a hard keyboard.

Ans: True.

 

  1. Method onOptionsItemSelected uses the selected MenuItem’s ________ to determine which one was selected.

Ans: resource ID

 

  1. Which of the following statements is false?
  2. Cursor method moveToFirst can be used to move the Cursor to the first row in the result set.
  3. It’s considered good practice to ensure that Cursor method moveToFirst returns true before attempting to get data from the Cursor.
  4. Class Cursor provides method getColumnIndexOrThrow if you prefer to get an exception when the specified column name does not exist.
  5. Android automatically releases resources like database connections when they are not being used so that other activities can use the resources.

Ans: d. Android automatically releases resources like database connections when they are not being used so that other activities can use the resources. [Actually, it’s good practice to for your app to explicitly release resources like database connections when they are not being used so that other activities can use the resources.]

  • DatabaseConnector Utility Class
  1. (True/False) Database names must be unique across apps.

Ans: False. Actually, database names must be unique within a specific app but need not be unique across apps.

 

  1. (True/False) Once a database is opened successfully, it will be cached by the operating system to improve the performance of future database interactions.

Ans: True.

 

  1. (True/False) SQLite does not support inserting a completely empty row into a database table.

Ans: True. But there is a workaround: Instead of making it illegal to pass an empty ContentValues to SQLiteDatabase’s insert method, the nullColumnHack parameter, which is the method’s second parameter) is used to identify a column that accepts NULL values.

 

  1. In the context of using SqLiteDatabase’s query method the Cursor returned by method query contains all the table rows that match the method’s arguments—the so-called ________.

Ans: result set

 

  1. If you supply a newer version number than the database version currently stored on the device, the DatabaseOpenHelper’s onUpgrade method will be called to ________.

Ans: upgrade the database to the new version (perhaps to add tables or to add columns to an existing table)

 

  1. (True/False) Class SQLite-OpenHelper also provides the onDowngrade method that can be used to downgrade a database when the currently stored version has a higher version number than the one requested in the call to class SQLite-OpenHelper’s constructor.

Ans: True.

 

  1. Why might you use downgrading on a SQLite database?

Ans: Downgrading might be used to revert the database back to a prior version with fewer columns in a table or fewer tables in the database—perhaps to fix a bug in your app.

Reviews

There are no reviews yet.

Be the first to review “Android How To Program 3rd Edition By Deitel & Deitel – Test Bank”

Your email address will not be published. Required fields are marked *