Deck 6: Cannon Game App
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/30
Play
Full screen (f)
Deck 6: Cannon Game App
1
Pass ________ to an AudioAttributes.Builder object’s setUsage method to indicate that the audio is being used as game audio.
A) AudioAttribute.USAGE_GAME
B) AudioAttribute.GAME
C) AudioAttribute.GAME_USAGE
D) None of the above
A) AudioAttribute.USAGE_GAME
B) AudioAttribute.GAME
C) AudioAttribute.GAME_USAGE
D) None of the above
AudioAttribute.USAGE_GAME
2
Games, often require complex logic that should be performed in separate threads of execution, and those threads often need to draw to the screen. For such cases, Android provides class ________—a subclass of View that provides a dedicated drawing area in which other threads can display graphics on the screen in a thread-safe manner.
A) GameView
B) ThreadView
C) ThreadSafeView
D) SurfaceView
A) GameView
B) ThreadView
C) ThreadSafeView
D) SurfaceView
SurfaceView
3
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.
A) Event
B) MotionEvent
C) Motion
D) View
A) Event
B) MotionEvent
C) Motion
D) View
MotionEvent
4
Class View’s onSizeChanged method is called whenever the View’s size chang-es, including when the View is first added to the View hierarchy as the layout is inflated. The method receives the View’s new width and height and its old width and height. The first time this method is called, the old width and height are ________ and ________.
A) 0, 0
B) 0, 1
C) 1, 0
D) 1, 1
A) 0, 0
B) 0, 1
C) 1, 0
D) 1, 1
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
5
When a View is inflated, its constructor is called with a Context and a(n) ________ as arguments.
A) SetOfAttributes
B) Attributes
C) OptionsSet
D) AttributeSet
A) SetOfAttributes
B) Attributes
C) OptionsSet
D) AttributeSet
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
6
Which of the next three statements is false?
A) Full-screen immersive mode enables an app to take advantage of the entire screen.
B) When an app is in immersive mode, the user can swipe down from the top of the screen to display the system bars temporarily.
C) If the user does not interact with the system bars, they disappear after a few seconds.
D) All of the above are true.
A) Full-screen immersive mode enables an app to take advantage of the entire screen.
B) When an app is in immersive mode, the user can swipe down from the top of the screen to display the system bars temporarily.
C) If the user does not interact with the system bars, they disappear after a few seconds.
D) All of the above are true.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
7
There are seven sound streams identified by AudioManager constants. The mu-sic stream ________ is recommended for sound in games, because this stream’s volume can be controlled via the device’s buttons.
A) AudioManager.STREAM
B) AudioManager.MUSIC
C) AudioManager.STREAM_MUSIC
D) AudioManager.SYMPHONY
A) AudioManager.STREAM
B) AudioManager.MUSIC
C) AudioManager.STREAM_MUSIC
D) AudioManager.SYMPHONY
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
8
Each SurfaceView subclass should implement the interface ________, which contains methods that are called when the SurfaceView is created, changed (e.g., its size or orientation changes) or destroyed.
A) SurfaceHolder.Callback
B) SurfaceHolderCallback
C) Surface.Callback
D) SurfaceCallback
A) SurfaceHolder.Callback
B) SurfaceHolderCallback
C) Surface.Callback
D) SurfaceCallback
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
9
All updates to an app's user interface must be performed in the GUI thread of execution, because GUI components are not ________.
A) thread ready
B) thread safe
C) thread capable
D) None of the above
A) thread ready
B) thread safe
C) thread capable
D) None of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following statements is false?
A) More complex games might play many sounds at the same time. SoundPool.Builder's setMaxStreams method takes an argument that represents the maximum number of simultaneous sound streams that can play at once.
B) A SparseIntArray maps integer keys to integer values. HashMap is similar to-but more efficient than-a SparseIntArray for small numbers of key-value pairs.
C) Each sound ID can be used to play a sound (and later to return its resources to the system).
D) SoundPool method load receives three arguments-the application's Context, a resource ID representing the sound file to load and the sound's priority.
A) More complex games might play many sounds at the same time. SoundPool.Builder's setMaxStreams method takes an argument that represents the maximum number of simultaneous sound streams that can play at once.
B) A SparseIntArray maps integer keys to integer values. HashMap
C) Each sound ID can be used to play a sound (and later to return its resources to the system).
D) SoundPool method load receives three arguments-the application's Context, a resource ID representing the sound file to load and the sound's priority.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the next three statements is false?
A) You can add a Fragment and its layout manually.
B) You can design an app for only landscape orientation.
C) To set the screen orientation to landscape, set android:-orientation to landscape.
D) Each of the above is true.
A) You can add a Fragment and its layout manually.
B) You can design an app for only landscape orientation.
C) To set the screen orientation to landscape, set android:-orientation to landscape.
D) Each of the above is true.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
12
A Frame-Layout is designed to display one View, but can also be used to ________ views.
A) stack
B) nest
C) position
D) layer
A) stack
B) nest
C) position
D) layer
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
13
An app’s sound effects are managed with a(n) ________ (package an-droid.media), which can be used to load, play and unload sounds.
A) Effects
B) SoundPool
C) EffectsPool
D) SoundManager
A) Effects
B) SoundPool
C) EffectsPool
D) SoundManager
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
14
Canvas's ________ method draws a circle.
A) drawOval
B) drawEllipse
C) drawCircle
D) None of the above
A) drawOval
B) drawEllipse
C) drawCircle
D) None of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
15
Sounds are played using one of Android’s audio- ________ for alarms, music, notifications, phone rings, system sounds, phone calls and more.
A) streams
B) players
C) tools
D) None of the above
A) streams
B) players
C) tools
D) None of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
16
Game-development frameworks typically provide sophisticated ________ collision-detection capabilities.
A) pixel-based
B) perfect
C) pixel-perfect
D) None of the above
A) pixel-based
B) perfect
C) pixel-perfect
D) None of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following statements is false?
A) 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.
B) We used the onDestroy method in the MainActivityFragment to release the CannonView's sound resources.
C) Method onDestroy is guaranteed to be called, so it can be used to release resources and to save critical data.
D) The Android documentation recommends that you save data in methods onPause or onSaveInstanceState.
A) 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.
B) We used the onDestroy method in the MainActivityFragment to release the CannonView's sound resources.
C) Method onDestroy is guaranteed to be called, so it can be used to release resources and to save critical data.
D) The Android documentation recommends that you save data in methods onPause or onSaveInstanceState.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
18
Game developers often use full-screen themes, such as Theme.Material.Light.NoActionBar.Fullscreen
That display only the bottom system bar, which in landscape orientation appears at the screen's ________.
A) top
B) bottom
C) left edge
D) right edge.
That display only the bottom system bar, which in landscape orientation appears at the screen's ________.
A) top
B) bottom
C) left edge
D) right edge.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following statements is false?
A) You configure and create a SoundPool object using a SoundPool.Builder object.
B) You use an AudioAttributes.Builder object to create an AudioAttributes object that will be associated with the SoundPool.
C) AudioAttributes’s setGameAudio method is used to designate the audio as game audio.
D) Activity’s setVolumeControlStream method allows the game’s volume to be controlled with the device’s volume buttons.
A) You configure and create a SoundPool object using a SoundPool.Builder object.
B) You use an AudioAttributes.Builder object to create an AudioAttributes object that will be associated with the SoundPool.
C) AudioAttributes’s setGameAudio method is used to designate the audio as game audio.
D) Activity’s setVolumeControlStream method allows the game’s volume to be controlled with the device’s volume buttons.
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
20
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.
A) phone audio stream
B) alarm audio stream
C) notifications audio stream
D) music audio stream
A) phone audio stream
B) alarm audio stream
C) notifications audio stream
D) music audio stream
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
21
Class SoundPool's ________ method gives the resources associated with a SoundPool back to the system.
A) reset
B) release
C) reinitialize
D) restore
A) reset
B) release
C) reinitialize
D) restore
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
22
Methods getScreenWidth and getScreenHeight return the width and height of the screen, which are updated in the ________ method.
A) onOrientationChanged
B) onSizeChanged
C) onConfigurationChanged
D) None of the above
A) onOrientationChanged
B) onSizeChanged
C) onConfigurationChanged
D) None of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
23
Method surfaceCreated is called when the SurfaceView is created-e.g., ________.
A) when the app first loads
B) when the app resumes from the background
C) Both of the above
D) Neither of the above
A) when the app first loads
B) when the app resumes from the background
C) Both of the above
D) Neither of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
24
View method onTouchEvent determines when the user touches the screen. The MotionEvent parameter contains information about the event that occurred. If the user touched the screen, the parameter’s value is ________.
A) MotionEvent.ACTION_DOWN
B) MotionEvent.ACTION_TOUCH
C) MotionEvent.ACTION_TAP
D) MotionEvent.ACTION_DRAG
A) MotionEvent.ACTION_DOWN
B) MotionEvent.ACTION_TOUCH
C) MotionEvent.ACTION_TAP
D) MotionEvent.ACTION_DRAG
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
25
Method ________ of interface SurfaceHolder.Callback is called when the SurfaceView's size or orientation changes, and would typically be used to redisplay graphics based on those changes.
A) surfaceSizeChanged
B) surfaceOrientationChanged
C) onSizeChanged
D) surfaceChanged
A) surfaceSizeChanged
B) surfaceOrientationChanged
C) onSizeChanged
D) surfaceChanged
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
26
You can call Canvas's drawRect method to clear the Canvas. The method receives the rectangle's upper-left x-y coordinates, width and height, and the ________ object that specifies the drawing characteristics.
A) Draw
B) PaintSettings
C) Paint
D) DrawSettings
A) Draw
B) PaintSettings
C) Paint
D) DrawSettings
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
27
A dialog must be displayed from the GUI thread. You call Activity method ________ to specify a Runnable that should execute in the GUI thread.
A) runOnUiThread
B) executeOnUIThread
C) uiThread
D) None of the above
A) runOnUiThread
B) executeOnUIThread
C) uiThread
D) None of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
28
Only one thread at a time can draw to a SurfaceView. To ensure this, you must first lock the SurfaceHolder by ________.
A) calling lockSurfaceHolder
B) specifying it as the expression in the parentheses of a synchronized block.
C) calling getSurfaceHolderLock
D) None of the above
A) calling lockSurfaceHolder
B) specifying it as the expression in the parentheses of a synchronized block.
C) calling getSurfaceHolderLock
D) None of the above
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
29
You can terminate a Thread by calling its setRunning method with the argument ________.
A) terminate
B) true
C) kill
D) false
A) terminate
B) true
C) kill
D) false
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck
30
To obtain the Canvas for drawing on the SurfaceView, call SurfaceHolder method ________.
A) getCanvas
B) createCanvas
C) newCanvas
D) lockCanvas
A) getCanvas
B) createCanvas
C) newCanvas
D) lockCanvas
Unlock Deck
Unlock for access to all 30 flashcards in this deck.
Unlock Deck
k this deck