Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz 03 - Variables

Total questions: 10

Worksheet time: 50mins

Name
Class
Date
1.

Which of the following is the correct way to declare a variable called "hours" to store the integer 8?

a)

hours = 8;

b)

hour = int(8);

c)

int hours = 8;

d)

int hours = 8

2.

What does the following instruction do?

unitPrice = 7.99;

a)

change the value of unitPrice to 7.99

b)

create a memory box to hold 7.99

c)

set the inital value of unitPrice to 7.99

d)

check if the value of unitPrice equals 7.99

3.

Which of the following is an appropriate variable name?

a)

lastname

b)

lastName

c)

LastName

d)

LAST_NAME

4.

Which of the following is a correct way to print text containing a variable's value?

a)

System.out.println("Hello " + name + "!");

b)

System.out.println("Hello " & name & "!");

c)

System.out.println("Hello " name "!");

d)

System.out.println("Hello ", name, "!");

5.

Which of the following is an appropriate name for a constant?

a)

gravitationalConstant

b)

GRAVITATIONALCONSTANT

c)

GravitationalConstant

d)

GRAVITATIONAL_CONSTANT

6.

Which variable type should be used to store the number of items in stock at a grocery store?

a)

int

b)

long

c)

double

d)

String

7.

Which variable type should be used to store the name of an item in a grocery store?

a)

int

b)

long

c)

double

d)

String

8.

Which variable type should be used to store 13-digit serial number of an item in a grocery store?

a)

int

b)

long

c)

double

d)

String

9.

Which variable type should be used to store the price of an item in a grocery store?

a)

int

b)

long

c)

double

d)

String

10.

Which statement will define a constant?

a)

static int HOURS_PER_DAY = 24;

b)

final int HOURS_PER_DAY = 24;

c)

int HOURS_PER_DAY = 24;

d)

constant int HOURS_PER_DAY = 24;