




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. What is the primary purpose of the MonoBehaviour class in Unity? A) To manage game assets B) To handle scripting behaviors of game objects C) To control rendering pipelines D) To optimize memory usage Answer: B Explanation: MonoBehaviour is the base class from which every Unity script derives, enabling scripting behaviors attached to game objects. Question 2. Which method is called once when a Unity script instance is enabled but before any Update calls? A) Awake B) Start C) OnEnable D) Initialize Answer: C Explanation: OnEnable is invoked when the script is enabled, which occurs before the first frame update, making it ideal for initialization.
Question 3. What is the correct order of the Unity scripting lifecycle methods when a scene starts? A) Awake, Start, Update B) Start, Awake, Update C) Update, Awake, Start D) Awake, Update, Start Answer: A Explanation: The order is Awake (called when the script instance is being loaded), then Start (called before the first frame update), followed by Update in each frame. Question 4. Which keyword is used to declare a constant in C#? A) var B) readonly C) const D) static Answer: C Explanation: The 'const' keyword declares a compile-time constant whose value cannot be changed after declaration.
Question 7. Which namespace contains core Unity engine classes? A) System.Collections B) UnityEngine C) System.IO D) UnityEditor Answer: B Explanation: The UnityEngine namespace includes classes essential for Unity scripting, such as GameObject, Transform, and MonoBehaviour. Question 8. What is the primary purpose of the Input Manager in Unity? A) To manage game data B) To handle user input from devices C) To control scene loading D) To optimize rendering Answer: B Explanation: The Input Manager processes user input from devices like keyboard, mouse, and controllers.
Question 9. Which Unity method is best suited for physics-based movement updates? A) Update B) FixedUpdate C) LateUpdate D) OnRenderObject Answer: B Explanation: FixedUpdate is called at consistent intervals and is suitable for physics calculations and movement. Question 10. Which scripting best practice enhances code readability in Unity? A) Using large monolithic scripts B) Using descriptive variable and method names C) Avoiding comments altogether D) Writing all code in the Start method Answer: B Explanation: Descriptive names improve code clarity and maintainability.
A) Singleton B) Observer C) Factory D) Decorator Answer: B Explanation: The Observer pattern facilitates event-driven communication through subscriptions and notifications. Question 14. Which Unity feature is suitable for creating a finite state machine for AI? A) Coroutines B) ScriptableObjects C) State Machine pattern D) Event triggers Answer: C Explanation: The State Machine pattern models different states and transitions for AI behaviors. Question 15. Object pooling in Unity helps to: A) Increase memory consumption
B) Reduce runtime instantiation costs C) Manage scene hierarchy D) Load assets asynchronously Answer: B Explanation: Object pooling reuses objects to minimize expensive instantiation and destruction. Question 16. Which design pattern is most appropriate for separating UI logic from game logic? A) MVC B) Singleton C) Observer D) Factory Answer: A Explanation: Model-View-Controller (MVC) separates data (model), UI (view), and input handling (controller). Question 17. Dependency Injection in Unity is primarily used to: A) Reduce coupling and improve testability B) Manage scene transitions
C) Stack D) HashSet Answer: B Explanation: Lists or Dictionaries allow flexible management and quick access to inventory items. Question 20. Raycasting in Unity is used primarily for: A) Detecting object interactions B) Rendering graphics C) Managing audio D) Loading scenes Answer: A Explanation: Raycasting projects a ray into the scene to detect objects for interactions like shooting or selection. Question 21. Which Unity class allows saving game data in PlayerPrefs? A) PlayerPrefs B) Serializer C) SaveManager
D) DataStore Answer: A Explanation: PlayerPrefs is a simple API for storing and retrieving player preferences and small data. Question 22. JSONUtility in Unity is used for: A) Saving binary data B) Serializing and deserializing objects to/from JSON C) Managing network connections D) Handling audio playback Answer: B Explanation: JSONUtility converts objects to JSON strings and back, facilitating data serialization. Question 23. Which method is suitable for loading scenes asynchronously? A) SceneManager.LoadScene B) SceneManager.LoadSceneAsync C) Application.LoadLevel D) SceneManager.LoadSceneImmediate
Explanation: Instantiate creates a copy of a prefab or object in the scene during runtime. Question 26. Which component is used to implement physics-based character movement in Unity 2D? A) Rigidbody2D B) Rigidbody C) Physics2D D) Collider Answer: A Explanation: Rigidbody2D enables physics simulation for 2D objects, including movement and collisions. Question 27. Which collider type is best suited for detecting triggers without physical collision response? A) BoxCollider B) SphereCollider C) Collider (set as trigger) D) MeshCollider Answer: C
Explanation: Colliders set as triggers detect overlaps without causing physical collision responses. Question 28. Which Animator parameter type is used to transition between animations via booleans? A) Float B) Int C) Bool D) Trigger Answer: C Explanation: Bool parameters are true/false variables used to control animation transitions. Question 29. How can you control animation transitions through scripts? A) Using Animator.SetTrigger, SetBool, SetFloat, SetInt B) Modifying animation files directly C) Changing scene lighting D) Adjusting physics layers Answer: A
Question 32. To make UI elements respond to user clicks, which component must be added? A) Canvas B) EventTrigger or Button component C) Rigidbody D) Collider Answer: B Explanation: EventTrigger or Button components enable input responses for UI elements. Question 33. To organize UI layout responsively, which Unity component is recommended? A) Canvas B) Layout Group (GridLayoutGroup, VerticalLayoutGroup, HorizontalLayoutGroup) C) Rigidbody D) Renderer Answer: B
Explanation: Layout groups help arrange UI elements dynamically based on screen size and resolution. Question 34. Which audio component is used to control background music in Unity? A) AudioSource B) AudioListener C) AudioMixer D) AudioClip Answer: A Explanation: AudioSource plays audio clips, including background music and sound effects. Question 35. For advanced audio control, which Unity feature allows mixing multiple audio sources? A) AudioListener B) AudioMixer C) AudioSource D) AudioClip Answer: B
Explanation: Debug.DrawRay displays a visual representation of rays in the Scene view for debugging. Question 38. Which framework is integrated with Unity for unit testing? A) NUnit B) JUnit C) MSTest D) xUnit Answer: A Explanation: Unity Test Framework supports NUnit for writing and running tests. Question 39. Profiling in Unity helps identify: A) Memory leaks and bottlenecks B) Asset import issues C) Shader compilation errors D) Scene hierarchy errors Answer: A
Explanation: The Unity Profiler helps analyze performance and memory usage during runtime. Question 40. To reduce garbage collection caused by frequent allocations, developers should: A) Use object pooling B) Use new objects frequently C) Avoid profiling D) Increase scene complexity Answer: A Explanation: Object pooling reuses objects, minimizing unnecessary allocations and garbage collection. Question 41. Which approach is most effective for reducing draw calls in Unity? A) Batching static objects B) Increasing polygon count C) Using unoptimized shaders D) Loading large textures Answer: A