NEW
Font size
WorksheetsCompuScholar Chapter 6 Exam
Total questions: 20
Worksheet time: 10mins
Which of the following best describes "primitive" data?
A single value that relies on other objects or logic to make it meaningful
A complex object with behavior and properties
An early data type that has been replaced by more modern types
An object that does something very simply
Which of the following data types can hold a fractional (decimal) number?
float
int
long
char
Which of the following examples correctly defines a single character value that can be stored in a char data type?
'x'
"x"
x
(x)
Which of the following examples successfully declares and initializes a double data type?
double myData = 1.5;
myData = 1.5D;
myData double = 1.5F;
double = myData;
Which of the following variable names is invalid?
2 funny
2funny2
FUNNY_2
All the them
Given the code below, what value is stored in the answer variable? int answer = 4 * 2;
8
2
6
12
Given the code below, what value is stored in the answer variable? int health = 10; int answer = health - 5;
5
15
10
0
8. Given the code below, what value is stored in the answer variable? int answer = 3 + (4 * 3) / 6;
5
4
3
6
Given the code below, what value is stored in the answer variable? float answer = 3 / 2;
1.0
1.5
2.0
An error will occur
Which of the following statements will decrease the value of the "health" variable by 1?
All of these will work
health -= 1;
health -= 1; health--;
health = health - 1;
Which of the following best describes a local variable?
Created and destroyed inside a function and visible only to the function
Created when a class is created and destroyed when the class is destroyed
Visible to all functions within a class
Works correctly only in certain areas of the country
Where should you declare a variable that you want to live for the lifetime of the class and be visible to all functions within the class?
Inside the class curly braces but outside of any function
Inside the curly braces belonging to any function
Outside of the class curly braces entirely
Above the "using" statements at the top of the script
What is the purpose of indenting code?
To make it easier to read and understand by humans
To make it easier to read by computers
To make it run faster
To meet the requirements of the C# language
. Given the code below, in which function or functions is the mystery variable in-scope? public class
MyScript : MonoBehaviour
{ int mystery = 1;
void Start()
{
}
void Update()
{
}
Both Start() and Update()
Update() only
Start() only
Not in-scope in any function
15. What is one advantage of marking a class member variable as "public" in a Unity project?
Initial values can be set directly from the Unity IDE
The variable will be hidden from all other classes
The variable can be modified only by your script's code
The variable can hold more than one value
16. When you add a Canvas to a Unity project, where does it appear?
In the Hierarchy panel
In the Inspector panel
In the Assets area
In the Visual Studio IDE
17. What is the purpose of the "Pos X" and "Pos Y" settings on the Text object?
To adjust the text location relative to the current anchor point
To set the text location's absolute X and Y coordinates on the screen
To set the width and height of the text box
To set the size of the text within the text box
Which of the following things can you change about the appearance of Text on the scene?
All of these are true
Size
Text color
Overflow behavior
Given a Text variable named "playerHealth", which of the following lines of code will successfully set the variable's string contents to "Critical"?
playerHealth.text = "Critical";
playerHealth = "Critical";
Text.playerHealth("Critical");
playerHealth.setText("Critical");
Which of the following statements about a Text object in the Hierarchy and a Text variable in a scriptare true?
They are linked by dragging the Text object onto the script variable in the Inspector panel
The object and variable names must always be the same
You will often see multiple script Text variables linked to the same Text object
All of these are true
