wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Lec 4b - Decisions

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.

A condition which is built up from two or more sub-conditions is called a...

a)

Boolean operator

b)

Compound condition

c)

Logical operator

2.

The operator placed between two sub-conditions is called a...

a)

Boolean operator

b)

Compound condition

c)

Logical operator

3.

What is the value of z given the following logical decision:

a)

z = TRUE

b)

z = FALSE

4.

Consider the two integer variables:


i1 = 10

i2 = 5


What is the outcome of the logical condition:


!((i1 + i2) > (i2 * i1))

a)

True

b)

False

5.

What is the logical equivalent of the following statement:


!(age > 10)

a)

(age < 10)

b)

(age <= 10)

c)

!(age == 10)

6.

The logical decision :


if (mGateOpen)


can also be written as:

a)

if (mGateOpen == true)

b)

if (mGateOpen = true)

c)

if !(mGateOpen = false)

7.

What does the code snippet above do?

a)

Changes false to true

b)

Changes true to false

c)

All of the above

8.

If the method above is written, what line of code is executed after the method call processNumber(x) ?

a)

A

b)

B

c)

C

9.

Given the above embedded decision in a program, what would be the output if conditionA = TRUE and conditionB = FALSE?

a)

X

b)

Y

c)

Z

10.

Given the embedded decision in the program above, what would be the output of the program if conditionA = FALSE and conditionB = TRUE?

a)

X

b)

Y

c)

Z