wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CompuScholar Chapter 6 Exam

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

Which of the following best describes "primitive" data?

a)

A single value that relies on other objects or logic to make it meaningful

b)

A complex object with behavior and properties

c)

An early data type that has been replaced by more modern types

d)

An object that does something very simply

2.

Which of the following data types can hold a fractional (decimal) number?

a)

float

b)

int

c)

long

d)

char

3.

Which of the following examples correctly defines a single character value that can be stored in a char data type?

a)

'x'

b)

"x"

c)

x

d)

(x)

4.

Which of the following examples successfully declares and initializes a double data type?

a)

double myData = 1.5;

b)

myData = 1.5D;

c)

myData double = 1.5F;

d)

double = myData;

5.

Which of the following variable names is invalid?

a)

2 funny

b)

2funny2

c)

FUNNY_2

d)

All the them

6.

Given the code below, what value is stored in the answer variable? int answer = 4 * 2;

a)

8

b)

2

c)

6

d)

12

7.

Given the code below, what value is stored in the answer variable? int health = 10; int answer = health - 5;

a)

5

b)

15

c)

10

d)

0

8.

8. Given the code below, what value is stored in the answer variable? int answer = 3 + (4 * 3) / 6;

a)

5

b)

4

c)

3

d)

6

9.

Given the code below, what value is stored in the answer variable? float answer = 3 / 2;

a)

1.0

b)

1.5

c)

2.0

d)

An error will occur

10.

Which of the following statements will decrease the value of the "health" variable by 1?

a)

All of these will work

b)

health -= 1;

c)

health -= 1; health--;

d)

health = health - 1;

11.

Which of the following best describes a local variable?

a)

Created and destroyed inside a function and visible only to the function

b)

Created when a class is created and destroyed when the class is destroyed

c)

Visible to all functions within a class

d)

Works correctly only in certain areas of the country

12.

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?

a)

Inside the class curly braces but outside of any function

b)

Inside the curly braces belonging to any function

c)

Outside of the class curly braces entirely

d)

Above the "using" statements at the top of the script

13.

What is the purpose of indenting code?

a)

To make it easier to read and understand by humans

b)

To make it easier to read by computers

c)

To make it run faster

d)

To meet the requirements of the C# language

14.

. 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()

{

}

a)

Both Start() and Update()

b)

Update() only

c)

Start() only

d)

Not in-scope in any function

15.

15. What is one advantage of marking a class member variable as "public" in a Unity project?

a)

Initial values can be set directly from the Unity IDE

b)

The variable will be hidden from all other classes

c)

The variable can be modified only by your script's code

d)

The variable can hold more than one value

16.

16. When you add a Canvas to a Unity project, where does it appear?

a)

In the Hierarchy panel

b)

In the Inspector panel

c)

In the Assets area

d)

In the Visual Studio IDE

17.

17. What is the purpose of the "Pos X" and "Pos Y" settings on the Text object?

a)

To adjust the text location relative to the current anchor point

b)

To set the text location's absolute X and Y coordinates on the screen

c)

To set the width and height of the text box

d)

To set the size of the text within the text box

18.

Which of the following things can you change about the appearance of Text on the scene?

a)

All of these are true

b)

Size

c)

Text color

d)

Overflow behavior

19.

Given a Text variable named "playerHealth", which of the following lines of code will successfully set the variable's string contents to "Critical"?

a)

playerHealth.text = "Critical";

b)

playerHealth = "Critical";

c)

Text.playerHealth("Critical");

d)

playerHealth.setText("Critical");

20.

Which of the following statements about a Text object in the Hierarchy and a Text variable in a scriptare true?

a)

They are linked by dragging the Text object onto the script variable in the Inspector panel

b)

The object and variable names must always be the same

c)

You will often see multiple script Text variables linked to the same Text object

d)

All of these are true