Unit 4: Programming - Practice Quiz

CSE434 — Game Development In 3D 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is a scripting language mainly used for in game development?

Scripting Language Easy
A. Compressing video files
B. Designing circuit boards
C. Defining game behavior
D. Manufacturing controllers

2 Which scripting language is commonly used with the Unity game engine?

Scripting Language Easy
A. HTML
B. C#
C. CSS
D. SQL

3 What is a variable in a game script?

Scripting Language Easy
A. A graphical user interface
B. A type of sound effect
C. A three-dimensional model
D. A named storage location

4 Which programming structure is used to make a decision in a game script?

Scripting Language Easy
A. An if statement
B. A texture map
C. An audio clip
D. A mesh filter

5 What is a game architecture pattern?

Game Architecture Patterns Easy
A. A method of drawing textures
B. A reusable design solution
C. A format for video export
D. A collection of sound files

6 Why are architecture patterns used in game development?

Game Architecture Patterns Easy
A. To organize game code
B. To increase monitor size
C. To record voice acting
D. To manufacture graphics cards

7 Which of the following is a game architecture pattern?

Game Architecture Patterns Easy
A. Polygon
B. Texture
C. Observer
D. Keyframe

8 What does the State pattern represent?

State Pattern Easy
A. Different sounds based on format
B. Different models based on color
C. Different behaviors based on state
D. Different textures based on size

9 Which is an example of a player state?

State Pattern Easy
A. Jumping
B. Lighting
C. Rendering
D. Texturing

10 What happens during a state transition?

State Pattern Easy
A. A texture changes format
B. A sound becomes compressed
C. An object changes state
D. A model gains polygons

11 Which system is commonly implemented using the State pattern?

State Pattern Easy
A. Texture compression
B. Audio recording
C. Model sculpting
D. Character behavior

12 What does the Singleton pattern ensure?

Singleton Pattern Easy
A. A script has four variables
B. A class has one instance
C. A scene has one object
D. A class has four methods

13 Which game system is commonly designed as a Singleton?

Singleton Pattern Easy
A. Game manager
B. Wall texture
C. Enemy model
D. Footstep animation

14 How is a Singleton instance usually accessed?

Singleton Pattern Easy
A. Through a shared reference
B. Through an audio waveform
C. Through an animation frame
D. Through a texture channel

15 What is the main purpose of the Observer pattern?

Observer Pattern Easy
A. To compress background music
B. To create three-dimensional meshes
C. To calculate texture coordinates
D. To notify objects about events

16 In the Observer pattern, what does an observer do?

Observer Pattern Easy
A. Records player audio
B. Creates new textures
C. Listens for notifications
D. Renders every polygon

17 Which situation is a suitable use of the Observer pattern?

Observer Pattern Easy
A. Compressing an audio track
B. Updating the score display
C. Building a terrain mesh
D. Painting a character texture

18 What is a Scriptable Object commonly used to store in Unity?

Scriptable Objects Easy
A. Recorded keyboard input
B. Reusable game data
C. Rendered screen pixels
D. Physical controller parts

19 Which type of data could be stored in a Scriptable Object?

Scriptable Objects Easy
A. Network cables
B. Weapon statistics
C. Mouse hardware
D. Monitor settings

20 Where is a Scriptable Object typically saved in a Unity project?

Scriptable Objects Easy
A. As a screen pixel
B. As a shader pass
C. As a project asset
D. As a scene camera

21 A game script needs to move an enemy toward the player every frame. Which approach is most appropriate for calculating the movement direction?

Scripting Language Medium
A. Add the enemy and player positions and use the result directly
B. Multiply the enemy position by the player's rotation
C. Use the enemy's current velocity without checking the player position
D. Subtract the enemy position from the player position and normalize the result

22 A player-controlled object should respond to input, while its movement should remain consistent across different frame rates. Which implementation is most suitable?

Scripting Language Medium
A. Move the object by a fixed distance without using elapsed time
B. Read input once during initialization and reuse the original value
C. Read input in the frame loop and multiply movement by delta time
D. Read input only when the object collides with another object

23 A projectile script creates a new explosion effect when the projectile hits an enemy. What is the main reason to destroy or return the projectile after handling the collision?

Scripting Language Medium
A. To force the game engine to reload the current scene
B. To prevent repeated collision handling and unnecessary object accumulation
C. To make the enemy ignore all future projectiles
D. To increase the projectile's damage during the same collision

24 A game has separate systems for input, player movement, audio, and scoring. Which architectural principle most directly helps keep these systems manageable?

Game Architecture Patterns Medium
A. Allow every system to modify every other system's fields
B. Give each system a focused responsibility and a clear interface
C. Duplicate shared logic inside each system to avoid dependencies
D. Place all gameplay logic inside the player controller

25 A game mode contains separate code paths for exploration, combat, and dialogue. As more modes are added, the conditional logic becomes difficult to maintain. Which design improvement is most appropriate?

Game Architecture Patterns Medium
A. Copy the entire game controller once for every possible mode
B. Represent each mode as an interchangeable state or behavior object
C. Add more nested conditional statements to the same game-mode method
D. Store every mode's variables in one large global data structure

26 A UI panel must display player health, but it should not directly depend on the internal implementation of the health system. Which architectural choice best supports this requirement?

Game Architecture Patterns Medium
A. Allow the UI panel to edit the health system's private variables
B. Move the health calculations into the UI panel
C. Expose a small health interface or event rather than internal fields
D. Make the health system inherit from the UI panel

27 An enemy can be idle, chasing, attacking, or stunned. When the enemy becomes stunned, which State Pattern behavior is expected?

State Pattern Medium
A. The stunned state changes only the enemy's display name
B. The current state is replaced and the stunned state controls behavior
C. The enemy continues executing all previous state behaviors simultaneously
D. The enemy must restart the entire game scene before changing behavior

28 In an enemy state machine, the chase state detects that the player is within attack range. What is the cleanest response?

State Pattern Medium
A. Request a transition from the chase state to the attack state
B. Keep chasing and independently start attack logic in every frame
C. Create a second enemy object that begins attacking
D. Disable all enemy scripts until the player leaves the range

29 A player changes from swimming to walking. The swimming state needs to stop water-specific effects, while the walking state needs to set ground movement values. Which lifecycle arrangement is suitable?

State Pattern Medium
A. Put both transitions inside the rendering method
B. Use an exit method for swimming and an enter method for walking
C. Run the swimming initialization method continuously during walking
D. Reset every object in the scene whenever the player changes state

30 A state machine repeatedly switches between patrol and chase because the player is exactly at the detection boundary. Which solution most directly reduces this instability?

State Pattern Medium
A. Make both states execute their movement code at once
B. Remove all distance checks from the state machine
C. Use separate enter and exit thresholds for detection
D. Create a new patrol state every frame

31 A game needs one audio manager that can be accessed by multiple scenes. Which condition is essential for a typical Singleton implementation?

Singleton Pattern Medium
A. It requires every scene to contain a separate audio manager
B. It prevents the manager from storing any configuration data
C. It creates a new manager whenever a sound effect is requested
D. It ensures that only one manager instance remains available

32 A Singleton manager is created in two scenes that load additively. What problem can occur if duplicate instances are not handled?

Singleton Pattern Medium
A. Only the first manager can ever receive a method call
B. The game automatically converts both managers into one object
C. Both managers may respond to events and perform actions twice
D. The scenes become unable to contain any non-manager objects

33 Why should a Singleton reference be initialized before other systems attempt to use it?

Singleton Pattern Medium
A. It prevents dependent systems from receiving a missing reference
B. It guarantees that the Singleton cannot be destroyed during gameplay
C. It removes the need for the Singleton to contain any methods
D. It makes all Singleton methods execute on separate threads

34 The score UI should update whenever the player's score changes, without the scoring system directly referencing the UI. Which Observer Pattern design is suitable?

Observer Pattern Medium
A. The score system creates a new UI panel after every score change
B. The UI reads the score field continuously from every game object
C. The UI changes the score directly whenever it needs a refresh
D. The score system publishes an event that the UI subscribes to

35 A menu subscribes to a level-completed event whenever it opens. After opening and closing the menu several times, the completion sound plays repeatedly. What is the likely cause?

Observer Pattern Medium
A. The level-completed event is declared as a local variable
B. The menu uses an observer instead of a Singleton
C. The menu subscribes repeatedly without unsubscribing when it closes
D. The event contains too few parameters for the menu

36 Several systems must react when the player dies, including the camera, audio manager, and game-over UI. What is a key advantage of using the Observer Pattern here?

Observer Pattern Medium
A. The pattern guarantees that all observers execute in a fixed order
B. The death event can notify multiple systems without tightly coupling them
C. The player object no longer needs any logic related to death
D. Every observing system must inherit from the player controller

37 A designer needs to adjust the properties of ten enemy types without editing code. Which use of a Scriptable Object is most appropriate?

Scriptable Objects Medium
A. Replace all enemy behavior scripts with a single data asset
B. Create one scene object for every possible enemy configuration
C. Store temporary enemy transforms that change every frame
D. Store shared enemy configuration data in reusable asset instances

38 Two enemy instances use the same Scriptable Object containing health configuration. One enemy changes the asset's health value during play. What risk does this create?

Scriptable Objects Medium
A. Only the enemy's transform can be changed through the asset
B. The game engine prevents all runtime changes to Scriptable Objects
C. The Scriptable Object automatically creates a private copy for each enemy
D. The other enemy may observe the changed shared value as well

39 A weapon system uses Scriptable Objects for weapon definitions. Which data is generally better stored on the weapon instance rather than in the shared asset?

Scriptable Objects Medium
A. The sound effect associated with firing the weapon
B. The base damage value used by all weapons of that type
C. The current ammunition remaining in that specific weapon
D. The icon displayed for the weapon type

40 A designer wants to create new collectible item types in the editor by changing names, icons, and effects without modifying the item pickup script. Why are Scriptable Objects useful for this design?

Scriptable Objects Medium
A. They automatically implement collision detection for each collectible
B. They force every item type to use a different pickup script
C. They replace the need for item data to be stored anywhere
D. They separate item data from the pickup behavior that consumes it

41 A Unity game uses this C# property:

public Vector3 Position => transform.position;

Another script repeatedly reads Position inside a loop and assumes the value is a cached snapshot. Which statement correctly identifies the behavior?

Scripting Language Hard
A. Each read reevaluates transform.position, so values may differ within the loop
B. The value is refreshed only when Unity invokes the component's Update method
C. The compiler stores the first result in an automatically generated backing field
D. The expression is evaluated once when the component instance is constructed

42 A base Unity component declares protected virtual void Update(), and a derived component declares private void Update() without override. What is the most accurate consequence?

Scripting Language Hard
A. Unity may invoke the derived method, but polymorphic calls through the base type use the base method
B. C# rejects the derived class because Unity message methods cannot hide virtual methods
C. The derived method overrides the base method because its name and parameters are identical
D. Unity invokes both methods every frame because message methods are automatically chained

43 A coroutine executes yield return new WaitForSeconds(2f);. During the wait, Time.timeScale changes from 1 to 0.5. Which interpretation is correct?

Scripting Language Hard
A. The coroutine terminates because changing the time scale invalidates its yield instruction
B. The remaining wait follows scaled game time and therefore lasts longer in real time
C. The remaining wait follows unscaled time and therefore keeps its original real duration
D. The wait duration is fixed using the time scale captured when the object was created

44 A deterministic combat simulation must support rollback. Presentation code currently reads live Transform values and emits particles directly during simulation. Which architectural change best supports reliable resimulation?

Game Architecture Patterns Hard
A. Move particle emission into each combatant's state classes and replay every transition
B. Serialize every component before each frame and restore the entire scene during rollback
C. Separate pure simulation state from presentation and replay confirmed events afterward
D. Store all combat objects under one persistent scene root and rewind their transforms

45 A game has a PlayerController that reads input, applies movement, updates animation, plays audio, saves progress, and modifies UI. Which redesign most directly reduces the cost of changing one subsystem without affecting the others?

Game Architecture Patterns Hard
A. Split responsibilities behind explicit interfaces and coordinate them through a narrow controller
B. Place every operation in one coroutine so execution order remains centrally visible
C. Convert every operation into a static method called by the existing controller
D. Move all responsibilities into a larger base class shared by every controllable entity

46 An entity-component design allows arbitrary components, but a system silently assumes every entity with Velocity also has TransformData. Which approach best preserves composability while enforcing the system's requirement?

Game Architecture Patterns Hard
A. Make Velocity inherit from TransformData so the dependency is encoded by inheritance
B. Query only entities containing both Velocity and TransformData components
C. Automatically add TransformData whenever any component named Velocity is created
D. Catch missing-component exceptions and skip invalid entities during system execution

47 During AttackState.Update, the character can receive both a stun event and an animation-complete event in the same frame. Immediate transitions cause Exit and Enter methods to run twice. Which policy best preserves deterministic state behavior?

State Pattern Hard
A. Queue transition requests and resolve one using an explicit priority rule
B. Allow the most recently executed callback to determine the final active state
C. Suppress all transitions until neither callback has executed for one full frame
D. Call every requested state's Enter method and retain the last returned state

48 Two enemies share one PatrolState object. The state stores currentWaypoint as an instance field. What is the most robust correction if state objects are intended to remain shared?

State Pattern Hard
A. Move per-enemy waypoint progress into each enemy's context data
B. Reset currentWaypoint whenever either enemy enters the shared state
C. Mark currentWaypoint as static so all state instances use one value
D. Clone the enemy's transform before passing it to the shared state object

49 A character can be simultaneously grounded or airborne, armed or unarmed, and normal or poisoned. A flat state machine creates a separate class for every combination. Which design most directly avoids the combinatorial explosion?

State Pattern Hard
A. Replace all state objects with a singleton storing the character's current combination
B. Use orthogonal state regions or composed state machines for independent concerns
C. Use one state class containing Boolean flags for all combinations and transitions
D. Create a deeper inheritance hierarchy with one subclass for every combined condition

50 A state's Enter method subscribes to a damage event, and Exit unsubscribes. Destroying the owning GameObject can bypass the expected transition path. Which addition best prevents stale subscriptions?

State Pattern Hard
A. Make owner teardown explicitly dispose the active state and remove its subscriptions
B. Call the active state's Enter method again from OnDestroy before releasing it
C. Depend on garbage collection to remove the event subscription after object destruction
D. Change the event to static so subscribers survive scene and GameObject destruction

51 A Unity singleton uses DontDestroyOnLoad. Returning to the bootstrap scene creates another copy, and both instances execute Awake before one is destroyed. Which design most reliably prevents duplicate initialization side effects?

Singleton Pattern Hard
A. Claim the singleton in Awake, destroy duplicates immediately, and initialize only the winner
B. Use a static constructor to call Unity APIs before either scene instance reaches Awake
C. Destroy the older instance and let the newly loaded instance repeat initialization each time
D. Run initialization in Start, because duplicate objects are always destroyed before any Start call

52 With Unity's disabled domain reload option, a static singleton reference can persist after exiting Play Mode while its referenced object has been destroyed. What is the most appropriate mitigation?

Singleton Pattern Hard
A. Serialize the static reference so Unity restores it whenever Play Mode begins
B. Replace Unity's null comparison with ReferenceEquals in every singleton access
C. Reset static state through a subsystem-registration runtime initialization hook
D. Mark the static reference with DontDestroyOnLoad before leaving Play Mode

53 A multiplayer client needs one inventory service per local player, but the current InventoryManager.Instance exposes one global inventory. Which change best corrects the lifetime and ownership mismatch?

Singleton Pattern Hard
A. Keep one singleton and switch its internal data according to the last player who acted
B. Create one singleton subclass per player and select subclasses using player indices
C. Store every inventory in static dictionaries while retaining the same global service access
D. Create player-scoped inventory services and inject the appropriate instance into consumers

54 An event publisher iterates a mutable subscriber list. One observer unsubscribes itself during notification, causing the next observer to be skipped. Which implementation best preserves defined delivery semantics?

Observer Pattern Hard
A. Iterate over a snapshot of the subscriber list for the current notification
B. Disallow unsubscription permanently once the first notification has occurred
C. Restart iteration from the first subscriber after every unsubscription
D. Traverse the original list backward and require subscriptions to remain ordered

55 A static C# event stores an instance method from a scene object. The scene unloads, but the subscriber never unsubscribes. What is the principal failure mode?

Observer Pattern Hard
A. The subscriber retains the static publisher, forcing the publisher to unload with the scene
B. The publisher retains the subscriber through the delegate, delaying collection and enabling stale callbacks
C. Unity automatically converts the delegate to a weak reference after the scene unloads
D. The event invocation list is cleared automatically when any subscribed GameObject is destroyed

56 A combat event bus dispatches events immediately. Observer A responds to DamageApplied by publishing Death, while observer B expects to finish processing DamageApplied before any Death handlers run. Which mechanism best enforces that ordering?

Observer Pattern Hard
A. Reverse the subscriber list whenever an observer publishes a nested event
B. Invoke each observer on a separate thread and wait for every thread to finish
C. Sort observers alphabetically before every immediate event dispatch begins
D. Queue nested publications and drain them after the current dispatch completes

57 A replicated game sends HealthChanged notifications over an unreliable network. Duplicate packets occasionally arrive, causing UI animations to play twice. Which event design best enables observers to handle duplicates correctly?

Observer Pattern Hard
A. Include only the new health value and let every observer compare animation timestamps
B. Clear every observer's subscription immediately after receiving one health notification
C. Include an entity identifier and monotonic revision so observers can reject stale revisions
D. Assign each observer a random delay so duplicate notifications rarely execute together

58 Several enemies reference the same EnemyStats ScriptableObject. At runtime, one enemy reduces stats.currentHealth, and all enemies appear damaged. Which design best resolves the shared-state error?

Scriptable Objects Hard
A. Move current health into a static field indexed by the shared asset's display name
B. Mark currentHealth with HideInInspector so Unity creates one hidden value per enemy
C. Duplicate the asset automatically whenever any field changes during combat
D. Keep immutable base stats in the asset and store current health on each enemy instance

59 A runtime system must modify a ScriptableObject-based item definition without changing the shared asset or affecting other users of it. Which approach is most appropriate?

Scriptable Objects Hard
A. Change the asset directly and restore its values when the current scene unloads
B. Create a runtime clone with Instantiate and modify the clone
C. Wrap the shared asset in a singleton and modify it through the singleton reference
D. Load the same asset again through Resources.Load and modify the returned object

60 A ScriptableObject event channel retains listeners from a previous scene because subscribers registered in OnEnable but did not unregister. The channel asset remains loaded across scenes. Which lifecycle rule best fixes the issue?

Scriptable Objects Hard
A. Pair registration in OnEnable with unregistration in OnDisable
B. Register in Start and rely on scene unloading to edit the asset's invocation list
C. Register in Awake and clear every listener globally whenever one object is disabled
D. Register in constructors and unregister only when the application process exits