Deck 6: Cannon Game App

ملء الشاشة (f)
exit full mode
سؤال
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
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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.
سؤال
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
سؤال
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
سؤال
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
سؤال
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.
سؤال
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 Frame-Layout is designed to display one View, but can also be used to ________ views.

A) stack
B) nest
C) position
D) layer
سؤال
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
سؤال
Canvas's ________ method draws a circle.

A) drawOval
B) drawEllipse
C) drawCircle
D) None of the above
سؤال
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
سؤال
Game-development frameworks typically provide sophisticated ________ collision-detection capabilities.

A) pixel-based
B) perfect
C) pixel-perfect
D) None of the above
سؤال
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.
سؤال
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.
سؤال
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.
سؤال
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
سؤال
Class SoundPool's ________ method gives the resources associated with a SoundPool back to the system.

A) reset
B) release
C) reinitialize
D) restore
سؤال
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
سؤال
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
سؤال
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
سؤال
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
سؤال
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 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
سؤال
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
سؤال
You can terminate a Thread by calling its setRunning method with the argument ________.

A) terminate
B) true
C) kill
D) false
سؤال
To obtain the Canvas for drawing on the SurfaceView, call SurfaceHolder method ________.

A) getCanvas
B) createCanvas
C) newCanvas
D) lockCanvas
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/30
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
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
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
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
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
14
Canvas's ________ method draws a circle.

A) drawOval
B) drawEllipse
C) drawCircle
D) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
30
To obtain the Canvas for drawing on the SurfaceView, call SurfaceHolder method ________.

A) getCanvas
B) createCanvas
C) newCanvas
D) lockCanvas
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.