& Deitel – Test Bank
– Sample
Test
Chapter 6 Cannon Game App
• Introducti
on No
questions.
• Test-Driving the Cannon Game
App No questions.
• Technologies
Overview No questions.
• Using the Resource Folder res/raw
,Q1. Media files (such as the sounds we used in the Cannon Game
app), are placed in the app’s resource folder .
1. res/media
2. res/sounds
3. res/raw
4. res/
multimedia
Answer: c.
res/raw
• Activity and Fragment Lifecycle Methods
Q1. Which of the following statements is false?
1. When an Activity is shut down, its onDestroy method is
called, which in turn calls the onDestroy methods of all the
Fragments hosted by the Activity.
2. We used the onDestroy method in the MainActivityFragment
to release the CannonView’s sound resources.
3. Method onDestroy is guaranteed to be called, so it can be
used to release resources and to save critical data.
4. The Android documentation recommends that you save data in
methods onPause or onSaveInstanceState.
Answer: c. Method onDestroy is guaranteed to be called, so it can be
used to release resources and to save critical data. Actually, method
onDestroy is not guaranteed to be called, so it should be used only to
release resources, not to save critical data.
• Overriding View Method onTouchEvent
Q1. To process simple touch events in an app, override View
method onTouchEvent, then use constants from class (package
android.view) to test which type of event occurred and process it
accordingly.
1. Event
2. MotionEvent
3. Motion
4. View
Answer: b. MotionEvent
, • Adding Sound with SoundPool and AudioManager
Q1. An app’s sound effects are managed with a(n)
(package android.media), which can be used to load, play and
unload sounds.
1. Effects
2. SoundPool
3. EffectsPool
4. SoundManag
er Answer:
SoundPool
Q2. Sounds are played using one of Android’s audio- for
alarms, music, notifications, phone rings, system sounds, phone
calls and more.
1. streams
2. players
3. tools
4. None of the
above Answer: a.
streams
Q3. The Android documentation recommends that games use the
to play sounds, because that stream’s volume can be controlled
via the device’s volume buttons.
1. phone audio stream
2. alarm audio stream
3. notifications audio stream
4. music audio stream
Answer: d. music audio
stream
Q4. Which of the following statements is false?