NEW
Font size
S
M
L
XL
WorksheetsIntro to IF statements
Total questions: 13
Worksheet time: 11mins
Name
Class
Date
1.
How many choices are possible when using a single if-else statement?
a)
1
b)
2
c)
3
d)
4
2.
a)
Under
b)
Over
c)
Under the limit
d)
Over the limit
3.
a)
You lose the prize
b)
You lose
c)
You win
d)
You win the prize
4.
a)
You win the prize
b)
You lose
c)
You win
d)
You lose the prize
5.
Evaluate (to true or false) each of the following expressions:
14 >= 14
15 > 15
16 != 16
18 >= 19
14 >= 14
15 > 15
16 != 16
18 >= 19
a)
T, F, F, F
b)
T, T, T, T
c)
F, T, F, F
d)
F, T, T, F
6.
Evaluate the following expression:
2 + 2 == 4
2 + 2 == 4
a)
true
b)
false
c)
sometimes true
d)
only true on sundays
7.
Evaluate the following expression
Math.pow(2, 3) >= 9;
Math.pow(2, 3) >= 9;
a)
true
b)
false
c)
compile error
d)
only true when the Patriots win
8.
Which expression below would determine if a number was odd?
a)
number % 2 ==0
b)
number / 2 == 0
c)
number % 2 == 1
d)
number % 10 == number
9.
a)
Low bridge:
b)
Low bridge: proceed with caution.
c)
Proceed with caution.
d)
<nothing prints to the screen>
10.
Which Math class method below will determine the square root of a number?
a)
Math.sqrt(number)
b)
Math.squareRoot(number)
c)
Math.pow(number, 2)
d)
Math.abs(number)
11.
a)
Danger:
b)
Danger: deep water.
c)
Danger: deep water. No swimming allowed.
d)
deep water. No swimming allowed.
12.
Fill in the blank so people 18 years and older are told to vote.
if ( age _________ 18 ) System.out.println("too young!"); else System.out.println("GO VOTE!");a)
>
b)
>=
c)
<=
d)
<
13.
a)
true
b)
false
c)
depends on compiler
d)
sometimes
Reset
