Name:     ID: 
 
Email: 

C# in Unity Quiz 1

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

 1. 

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

 2. 

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?
mc002-1.jpg
a.
randomFloat = 100.0f;
randomInt = 100;
c.
randomFloat = 50.5f;
randomInt = 100;
b.
randomFloat = 100.0f;
randomInt = 0;
d.
randomFloat = 0.0f;
randomInt = 50.5;
 

 3. 

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

 4. 

Which comment would best describe the code below?

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

 5. 

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?
mc005-1.jpg
a.
6, 1, 2, 5, 7, 8, 3, 4, 9
c.
4, 6, 1, 2, 5, 9, 7, 8, 3
b.
7, 8, 3, 4, 6, 1, 2, 5, 9
d.
7, 8, 3, 4, 6, 5, 2, 1, 9
 

 6. 

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

 7. 

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

 8. 

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

 9. 

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

 10. 

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 C
c.
Line B
b.
Line D
d.
Line A
 

 11. 

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?
mc011-1.jpg
a.
The blue boc
c.
The red box
b.
The green box
 

 12. 

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

 13. 

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?
mc013-1.jpg
a.
Line 3
c.
Line 5
b.
Line 4
d.
Line 1
 

 14. 

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:
mc014-1.jpg
a.
GetKeyHeld(Vector3.Up)
c.
GetKey(KeyCode.UpArrow)
b.
GetKeyUp(KeyCode.Up)
d.
GetKeyDown(UpArrow)
 

 15. 

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?
mc015-1.jpg
a.
The “Open” button at the top of the Inspector
c.
The “Add Component” button at the bottom of the Inspector
b.
The “Overrides” drop-down at the top of the Inspector
d.
The “Create” drop-down at the top of the Hierarchy
 

 16. 

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?
mc016-1.jpg
a.
Either On line 1, change “GameObject[]” to “GameObject” or On line 5, change “enemyPrefabs” to “enemyPrefabs[0]”
e.
Both On line 1, change “enemyPrefabs” to “enemyPrefabs[0]” and On line 3, change “Start()” to  Update()” together
b.
On line 1, change “GameObject[]” to “GameObject”
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.
On line 5, change “enemyPrefabs” to “enemyPrefabs[0]”
d.
On line 1, change “enemyPrefabs” to “enemyPrefabs[0]”
 

 17. 

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

 18. 

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

 19. 

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

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

 20. 

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



 
         Start Over