Name:     ID: 
 
Email: 

C# in Unity Quiz 1

True/False
Indicate whether the statement is true or false.
 

 1. 

Visual Studio is not a part of Unity. You could use a different code editor to edit your C# scripts if you wanted to.
 

Multiple Choice
Identify the choice that best completes the statement or answers the question.
 

 2. 

Which Unity window contains a list of all the game objects currently in your scene?
a.
Scene view
c.
Hierarchy
b.
Project window
d.
Inspector
 

 3. 

What best describes the difference between the below images, where the car is in the second image is further along the road?
mc003-1.jpg
a.
The second car’s X location value is higher than the first car’s
c.
The second car’s Z location value is higher than the first car’s
b.
The second car’s Y location value is higher than the first car’s
d.
The second car’s Transform value is higher than the first car’s.
 

 4. 

In what order do you put the words when you are declaring a new variable?
public float speed = 20.0f;
a.
[data type] [access modifier][variable value] [variable name]
c.
[data type] [access modifier][variable name] [variable value
b.
[access modifier] [data type][variable name] [variable value]
d.
variable name] [data type][variable name] [data type]
 

 5. 

Which of the following variables would be visible in the Inspector?
mc005-1.jpg
a.
speed
c.
speed & turnSpeed
b.
turnSpeed
d.
horizontalInput & forwardInput
 

 6. 

What is a possible value for the horizontalInput variable?
mc006-1.jpg
a.
-10
c.
“Right”
b.
0.52
d.
Vector3.Up
 

 7. 

What is true about the following two lines of code?
mc007-1.jpg
a.
They will both move an object at the same speed
c.
They will both move an object along the same axis
b.
They will both move an object in the same direction
d.
They will both rotate an object, but along different axes
 

 8. 

Which of the following lines of code is using standard Unity naming conventions?
/* a */ Public Float Speed = 40.0f;
/* b */ public float Speed = 40.0f;
/* c */ Public float speed = 40.0f;
/* d */ public float speed = 40.0f;
a.
Line A
c.
Line C
b.
Line B
d.
Line D
 

 9. 

Which comment would best describe the code below?

horizontalInput = Input.GetAxis("Horizontal");
transform.Rotate(Vector3.up, horizontalInput);
a.
// Rotates around the Y axis based on left/right arrow keys
c.
// Rotates in an upward direction based on left/right arrow keys
b.
// Rotates around the Z axis based on up/down arrow keys
d.
// Moves object up/down based on the the left/right arrow keys
 

 10. 

The image below shows the preferences window that allows you to change which script editing tool (or IDE) you want to use. Where would you click to choose an alternative code editing tool?
mc010-1.jpg
a.
The red box
c.
The green box
b.
The blue boc
 

 11. 

If it says, “Hello there!” in the console, what was the code used to create that message?
a.
Debug(“Hello there!”);
c.
Debug.Console(“Hello there!”);
b.
Debug.Log("Hello there!");
d.
Debug.Log(Hello there!);
 

 12. 

If you want to destroy an object when its health reaches 0, what code would be best in the blank below?
mc012-1.jpg
a.
health > 0
c.
health < 1
b.
health.0
d.
health < 0
 

 13. 

The code below creates an error that says, “error CS1503: Argument 1: cannot convert from
'UnityEngine.GameObject[]' to 'UnityEngine.Object'”. What could you do to remove the errors?
mc013-1.jpg
a.
On line 1, change “GameObject[]” to “GameObject”
e.
Either On line 1, change “GameObject[]” to “GameObject” or On line 5, change “enemyPrefabs” to “enemyPrefabs[0]”
b.
On line 1, change “enemyPrefabs” to “enemyPrefabs[0]”
f.
Both On line 1, change “GameObject[]” to “GameObject” and On line 5, change “enemyPrefabs” to “enemyPrefabs[0]” together
c.
On line 3, change “Start()” to  Update()”
g.
Both On line 1, change “enemyPrefabs” to “enemyPrefabs[0]” and On line 3, change “Start()” to  Update()” together
d.
On line 5, change “enemyPrefabs” to “enemyPrefabs[0]”
 

 14. 

Which comment best describes the following code?
mc014-1.jpg
a.
// If player collides with another object, destroy player
c.
// If player collides with a trigger, destroy trigger
b.
// If enemy collides with another object, destroy the object
d.
// If player collides with another object, destroy the object
 

 15. 

If you want to move the character up continuously as the player presses the up arrow, what code would be best in the two blanks below:
mc015-1.jpg
a.
GetKey(KeyCode.UpArrow)
c.
GetKeyUp(KeyCode.Up)
b.
GetKeyDown(UpArrow)
d.
GetKeyHeld(Vector3.Up)
 

 16. 

Read the documentation from the Unity Scripting API and the code below. Which of the following are possible values for the randomFloat and randomInt variables?
mc016-1.jpg
a.
randomFloat = 100.0f;
randomInt = 0;
c.
randomFloat = 50.5f;
randomInt = 100;
b.
randomFloat = 100.0f;
randomInt = 100;
d.
randomFloat = 0.0f;
randomInt = 50.5;
 

 17. 

You are trying to randomly spawn objects from an array. However, when your game is running, you see in the console that there was an “error at Assets/Scripts/SpawnManager.cs:5. IndexOutOfRangeException: Index was outside the
bounds of the array.” Which line of code should you edit in order to resolve this problem and still retain the random object functionality?
mc017-1.jpg
a.
Line 1
c.
Line 4
b.
Line 3
d.
Line 5
 

 18. 

If you have made changes to a prefab in the scene and you want to apply those changes to all prefabs, what should you click?
mc018-1.jpg
a.
The “Create” drop-down at the top of the Hierarchy
c.
The “Overrides” drop-down at the top of the Inspector
b.
The “Open” button at the top of the Inspector
d.
The “Add Component” button at the bottom of the Inspector
 

 19. 

Read the documentation from the Unity Scripting API below. Which of the following is a correct use of the InvokeRepeating method?
mc019-1.jpg
a.
InvokeRepeating(“Spawn, 0.5f, 1.0f”);
c.
InvokeRepeating(“Spawn", gameObject, 1.0f);
b.
InvokeRepeating(“Spawn”, 0.5f, 1.0f);
d.
InvokeRepeating(0.5f, 1.0f, “Spawn”);
 

 20. 

You’re trying to create some logic that will tell the user to speed up if they’re going too slow or to slow down if they’re going too fast. How should you arrange the lines of code below to accomplish that?
mc020-1.jpg
a.
4, 6, 1, 2, 5, 9, 7, 8, 3
c.
7, 8, 3, 4, 6, 5, 2, 1, 9
b.
6, 1, 2, 5, 7, 8, 3, 4, 9
d.
7, 8, 3, 4, 6, 1, 2, 5, 9
 



 
         Start Over