Name:     ID: 
 
Email: 

Unity in C# Quiz 3

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

 1. 

If there is a boolean in script A that you want to access in script B, which of the following are true:
mc001-1.jpg
a.
1, 2, and 3 only
d.
3 and 4 only
b.
1 and 2 only
e.
1 only
c.
All are true
f.
2 and 3 only
 

 2. 

You run your game and get the following error message in the console, “NullReferenceException: Object reference not set to an instance of an object”. Given the image and code below, what would resolve the problem?
mc002-1.jpg
a.
In the hierarchy, rename “Game Manager” as “GameManager”
c.
On Line 3, remove the GetComponent code
b.
On Line 1, rename “GameManager” as “Game Manager”
d.
In the hierarchy, rename “Game Manager” to “gameManager”
 

 3. 

If you wanted a button to display the message, “Hello!” when a button was clicked, what code would you use to fill in the blank?
mc003-1.jpg
a.
(SendMessage(“Hello”));
c.
(SendMessage(Hello));
b.
(SendMessage(string Hello));
d.
(SendMessage);
 

 4. 

Which of the following is the correct way to declare a new List of game objects named “enemies”?
mc004-1.jpg
a.
Line 2
c.
Line 1
b.
Line 4
d.
Line 3
 

 5. 

Which code to fill in the blank will result in the object being destroyed?
mc005-1.jpg
a.
name == “player” && isDead != true && health > 5
c.
name = “player” && isDead && health < 5
b.
name == “player” && !isDead && health < 5
d.
name != “player” && isDead != true && health > 5
 

 6. 

You have declared a new Button variable as “private Button start;”, but there’s an error under the word “Button” that says “error CS0246: The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?)”
a.
“Button” should be lowercase
“button”
c.
New Button variables must be made public
b.
You are missing “using UnityEngine.UI;” from the top of your class
d.
You can’t name a button “start” because that’s the name of a Unity Event Function
 

 7. 

Read the Unity documentation below about the OnMouseDrag event and the code beneath it. What will the value of the “counter” variable be if the user clicked and held down the mouse over an object with a collider for 10 seconds?
mc007-1.jpg
a.
A value over 100
d.
99
b.
1
e.
100
c.
0
 

 8. 

Based on the code below, what will be displayed in the console when the button is clicked?
mc008-1.jpg
a.
“Welcome + Robert + Smith”
c.
“Welcome, firstName Smith”
b.
“Welcome, Robert Smith”
d.
“Button is ready”
 

 9. 

Which of the following follows Unity naming conventions (especially as they relate to capitalization)?
mc009-1.jpg
a.
Line 3
c.
Line 2
b.
Line 1
d.
Line 4
 

 10. 

Look at the documentation and code below. Which of the following lines would NOT produce an error?
mc010-1.jpg
a.
Line 6
c.
Line 8
b.
Line 7
d.
Line 5
 

Completion
Complete each statement.
 

 11. 

_______________________ are Unity’s default methods that run in a very particular order over the life of a script.
 

 

 12. 

What is the operator used in C# to output the remainder or Modulus?
 

 

 13. 

______________ is creating a reusable pool of objects that can be activated and deactivated rather than instantiated and destroyed, which is much more efficient.
 

 

 14. 

________________ is an attribute that allows protected access to derived classes.
 

 

 15. 

What is the Build type for projects to be uploaded and embedded online?
 

 



 
         Start Over