WorksheetsGame & Sim Programming Semester 1 Exam 21-22 Study Guide
Total questions: 60
Worksheet time: 15hrs 0mins
Which syntax is correct for printing the words "Welcome to the jungle" to the console?
Debug.log("Welcome to the jungle");
Debug.log("Welcome to the jungle")
Debug.Log("Welcome to the jungle");
Debug.log("welcome to the jungle");
Which of the following data types can hold a fractional (decimal) number?
bool
float
int
string
Which of the following data types can hold ONLY a whole number?
bool
float
int
string
Which of the following examples successfully declares and initializes an int data type?
int max = 1;
int = max;
max = 1000;
max int = 1000;
What symbols does C# use to start a short, one-line comment?
//
##
<!--
**
What characters are used to mark the start and end of a block of C# code such as a class or function?
# and #
/* and */
{ and }
Begin and End
Which function will be called on each object when a scene initializes?
Start()
Initialize()
Create()
Update()
Which function is called repeatedly within your game loop?
Loop()
Update()
Repeat()
Start()
The given code is not well-written. If playerHealth is equal to 50, which statement will you see in the console window?
Game Over!
Danger! Danger!
Ouchie...
No output at all
Given the code below, if the value of success is false, what output will appear in the console window?
Success
Failure
Success and Failure
No output at all
Given the following code, when the value of the score variable is 35, what message will be displayed?
Great job!
Room for improvement.
Are you awake?
No messages will be displayed
What do we mean when we say a variable is "out of scope"?
It has been defined as an instance variable and we are trying to access it locally in a specific method.
It's to the left or the right of our sites when camping from our favorite ledge.
It has been declared in a part of our code with is local to the variable but not local to where we are trying to access it.
It has reached its maximum value and cannot go any higher
Given the code below, in which function or functions is the mystery variable in-scope?
Start() only
Update() only
Both Start() and Update()
Not in-scope in any function
Given the code below, in which function or functions is the mystery variable in-scope?
Start() only
Update() only
Both Start() and Update()
Not in-scope in any function
Which kind of variable can be seen by any function within the class and will live as long as the parent object?
local
class-level
universal
global
What term is used to describe a variable that exists and is visible to a particular section of code?
public
private
in-scope
underwater
What new line of C# code should you add to the top of your script to enable access to the Text object?
using UnityEngine.UI;
using Text;
using Canvas;
access UI.Text;
Which of the following variables uses the proper name conventions?
playerscore
playerScore
PlayerScore
PLAYERSCORE
Given a Text variable named "playerHealth", which of the following lines of code will successfully set the variable's string contents to "Critical"?
playerHealth = "Critical";
Text.playerHealth("Critical");
playerHealth.text = ("Critical");
playerHealth.setText("Critical");
What keyword do you use in front of a function name to show the function returns no data?
null
void
empty
All functions must return some data
What keyword do you add to a function declaration so it will be visible outside the class?
public
visible
private
void
Which of the following lines correctly declares an array variable named "grades" that is of type "float"?
float[ ] grades;
grades[ ] float;
float(grades);
float grades;
Knowing that the 1st element in an array has index value 0, write an expression that shows how to access the 3rd element in an array called “friends”.
friends[0]
friends[1]
friends[2]
friends[3]
Which of the following statements is NOT placed inside the parentheses when defining a for() loop?
A return statement
An initialization statement
A conditional statement
An iteration statement
Which of the following for() loops defines an index variable that would safely access every element in the "friends" array, no matter how many elements it held?
for (int i=0; i < 5; i++)
for (int i=0; i < friends.Length; i++)
for (int i=0; i <= friends.Size(); i++)
for (int i=1; i <= friends.Length; i++)
The following function call will return random values in what range?int result = Random.Range(0, 7);
1, 2, 3, 4, 5, 6
0, 1, 2, 3, 4, 5, 6
1, 2, 3, 4, 5, 6, 7
1 or 7 only
What would the following code output to the Console window?
The values 0, 1, 2 in that order
The values 0, 1, 2, 3 in that order
The values 1, 2, 3 in that order
The values 1, 2 in that order
What would the following code output to the Console window?
The values 4, 3, 2, 1, 0 in that order
The values 3, 2, 1, 0 in that order
The values 4, 3, 2, 1 in that order
The values 0, 1, 2, 3, 4 in that order
Which of the following class variables can be freely read and modified by code outside the object?
private float cost;
[Seiarlizefield] int score;
protected string message;
visible bool gameOver;
Debug this code. We are trying to trigger OnPressHigher() from a button press, but it is not working. Why?
We have forgotten to add a semi-colon after our method declaration.
We always need to declare our min variable within the scope of the method - it is currently out of scope.
we have forgotten to add a return type to our method, it should not be void.
We have forgotten to add the public access modifier at the start of our method.
Which of the following statements will successfully load a scene indexed as "0"?
SceneManager.LoadScene (0);
Load("SecretRoom");
Scene.AddLevel("SecretRoom");
SceneManager.LoadScene ("0");
Let's debug some code. Why won't this code work as expected?
We have forgotten to add a semi-colon after LoadNextScene()
SceneManager should not have a capital 'S' given that it is referring to a class
We have forgotten to add a return type in our LoadNextScene() method - it should not be 'void'.
The name of the declared variable is different to the name of the variable we are passing in to our method.
Which of the following "using" statements should be placed at the top of a script that wants to change scenes?
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using Scenes;
using SceneManager;
When we play the game and click on the "Lower" Button nothing happens. Why is that?
We have not provided the appropriate sprite image.
Navigation is set to automatic.
We have not assigned an On Click Function
The button needs a material to be set.
If a Collider 2D object has "Is Trigger" checked (true), what is the difference in behavior?
The object will bounce off other objects and call a special trigger event function
The object will bounce off other objects and no collision event function will be called
A trigger event function will be called, but the object will not react to the physical collision
The object will not bounce off any other object and no collision event function will be called
Which of the following "using" statements should be placed at the top of a script that wants to change scenes?
using Scenes;
using UnityEngine.UI;
using SceneManager;
using UnityEngine.SceneManagement;
Which of the following statements will successfully load a new scene named "SecretRoom"?
Load("SecretRoom");
SecretRoom.LoadScene();
Scene.AddLevel("SecretRoom");
SceneManager.LoadScene ("SecretRoom");
Given the following code, which of the statements below is NOT correct?
Input needs to be spelled with upper case "I" because it is a class.
We are missing a semi-colon
The variable type is incorrect, it shouldn't be an integer
We must have parentheses around our formula
What code would we write to access the Rigidbody2D component of our game object and give it a shove up and to the left?
GetComponent<Rigidbody2D>.velocity = new Vector2(-3f,10f);
GetComponent<Rigidbody2D>().velocity = new Vector2(3f,10f);
GetComponent(Rigidbody2D)().velocity = new Vector2(-3f,10f);
GetComponent<Rigidbody2D>().velocity = new Vector2(-3f,10f);
What are the possible values you can store in the C# "bool" data type?
A or B
1 or 2
true or false
more or less
Which of the following functions can Unity call in response to a regular, physics-based collision event?
OnCollisionEnter2D()
Collided()
Triggered2D()
OnCollisionDetection()
Using his/your code, which phrase represents the parameter (data) that is passed into the function?
void
OnCollisionEnter2D
Collision2D collision
None of these is true
Which of the following would we use to remove an object from our hierarchy when we no longer want it to exist in our scene?
Destroy(gameObject);
destroy(gamObject);
Delete(gameObject);
Destory(this);
Which of the following lines of code will remove the object stored in the doomedObj reference variable from the game?
Delete(doomedObject);
doomedObject.Delete();
Destroy(doomedObject);
Remove<doomedObject>();
Which phrase would you add to the parameter name in a collision event function to get the name of the other object?
.name
name.Collision2D
.gameObject.name
.OnCollisionEnter2D.name
What Unity element would best be used to help you easily create many copies of the same object?
clone
prefab
copier
Teleporter
Using the given code, what is the timeScale set to?
0
1.0f
2.0f
10.0d
Which of the following statements is written correctly?
SceneLoader = FindObjectOfType<sceneLoader>();
sceneLoader = FindObjectOfType<SceneLoader>;
sceneLoader = FindObjectOfType<SceneLoader>();
sceneLoader = FindObjectOfType[SceneLoader]();
With the given code what object are you looking for?
foundObjects
TextMesh
FindObjectsOfType
There is not enough information to determine the object
Which of the following statements will decrease the value of the "health" variable by 1?
health = health - 1;
health -= 1;
health--;
All of these will work
The decrement operator is indicated by the symbol ____.
\\
++
-
--
The syntax of the if statement is ____.
if (for i, condition) { commands }
if [condition] { commands }
if (condition) { commands }
if commands (condition) { commands }
Which of the following will allow us to access the Audio Component on a specific Game Object?
FindOjbectOfType<AudioSource>()
GetCompnent<AudioSource>()
SetComponent<AudioSource>()
myAudioSource<AudioSource>()
Which of the following lines correctly declares an array variable named "ballSounds" that is of type "AudioClip"?
AudioClip[ ] ballSounds;
ballSounds[ ] AudioClip;
AudioClip(ballSounds);
AudioClip ballSounds;
The increment operator is indicated by the ____ symbol.
+
++
--
%
Given a Text variable named "scoreText", which of the following lines of code will successfully output the currentScore variable ToString()?
scoreText.text = currentScore.ToString();
scoreText = currentScore.ToString();
Text.scoreText(currentScore);
scoreText.setText(currentScore);
What is a reason that could be causing this error with Random as seen in the screenshot?
Random should random, that is, starting with a lowercase letter.
Lines 58, 59, and 60 are not allowed to be separated onto different lines.
Our Visual Studio spellchecker thinks that we have spelled random incorrectly.
We have a namespace conflict whereby 2 namespaces we are using contain reference to Random.
In the GameStatus script, we have a public method named ResetGame(). From another script, which of the following lines of code would successfully call the ResetGame() method?
FindObjectsOfType<GameStatus>.ResetGame();
FindObjectOfType<GameStatus>().ResetGame();
GetComponent<GameStatus>().ResetGame;
ResetGame(GameStatus);
Which of the following lines of code will spawn a new object based on the prefab stored in the myPrefab reference variable?
Instantiate(myPrefab);
Clone(myPrefab);
Copy(myPrefab);
myPrefab.Instantiate();
The ____ operator returns true if the values are not equal.
<=
>=
!=
=
