wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Computer Science: Chapter 2 Test Review

Total questions: 20

Worksheet time: 7mins

Name
Class
Date
1.

When data cannot be changed after a class is compiled, the data is __________.

a)

Constant

b)

Variable

c)

Volatile

d)

Mutable

2.

Which of the following is not a primitive data type in Java?

a)

Boolean

b)

Byte

c)

Int

d)

Sector

3.

Which of the following elements is not required in a variable declaration?

a)

A Type

b)

An Identifier

c)

An Assigned Value

d)

A Semicolon

4.

The assignment operator in Java is __________.

a)

=

b)

==

c)

:=

d)

::

5.

Assuming you have declared shoeSize to be a variable of type int, which of the following is a valid assignment statement in Java?

a)

shoeSize = 9;

b)

shoeSize = 9.5;

c)

shoeSize = '9';

d)

shoeSize = "nine";

6.

Which of the following data types can store a value in the least amount of memory?

a)

Short

b)

Long

c)

Int

d)

Byte

7.

A boolean variable can hold __________.

a)

Any Character

b)

Any Whole Number

c)

Any Decimal Number

d)

The Value True Or False

8.

The value 137.68 can be held by a variable of type __________.

a)

Int

b)

Float

c)

Double

d)

Float and Double Are Correct

9.

An escape sequence always begins with a(n) __________.

a)

E

b)

Forward Slash

c)

Backslash

d)

Equal Sign

10.

Which Java statement produces the following output?


w

xyz

a)

System.out.println("waxy");

b)

System.out.println("w" + "xyz");

c)

System.out.println("w\nxyz");

d)

System.out.println("w\nx\ny\nz");

11.

The remainder operator __________.

a)

Is Represented By A Forward Slash

b)

Must Follow A Division Operation

c)

Provides The Quotient Of Integer Division

d)

Is None Of The Above

12.

According to the rules of operator precedence, when division occurs in the same arithmetic statement as __________, the division operation always takes place first.

a)

Multiplication

b)

Remainder

c)

Subtraction

d)

Multiplication & Remainder Are Correct

13.

The "equal to" relational operator is __________.

a)

=

b)

==

c)

!=

d)

!!

14.

When you perform arithmetic with values of diverse types, Java __________.

a)

Issues An Error Message

b)

Implicitly Converts The Values To A Unifying Type

c)

Requires You To Explicitly Convert The Values To A Unifying Type

d)

Implicitly Converts The Values To The Type Of The First Operand

15.

If you attempt to add a float, an int, and a byte, the result will be a(n) __________.

a)

Float

b)

Int

c)

Byte

d)

Error Message

16.

You use a __________ to explicitly override an implicit type.

a)

Mistake

b)

Type Cast

c)

Format

d)

Type Set

17.

In Java, what is the value of 3 + 7 * 4 + 2?

a)

21

b)

33

c)

42

d)

48

18.

Which assignment is correct in Java?

a)

int value = (float) 4.5;

b)

float value = 4 (double);

c)

double value = 2.12;

d)

char value = 5c;

19.

Which assignment is correct in Java?

a)

double money = 12;

b)

double money = 12.0;

c)

double money = 12.0d;

d)

All Of The Above Are Correct

20.

Which assignment is correct in Java?

a)

char aChar = 5.5;

b)

char aChar = "W";

c)

char aChar = '*';

d)

char aChar = "W"; & char aChar = '*'; Are Correct