wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CodeHS Unit 5 - Booleans

Total questions: 25

Worksheet time: 14mins

Name
Class
Date
1.

Which is not a valid value for a Boolean?

a)

true

b)

false

c)

yes

d)

None of these are correct.

2.

Which symbol represents and in JavaScript?

a)

&&

b)

!

c)

==

d)

||

3.

Which symbol represents or in JavaScript?

a)

||

b)

&&

c)

>

d)

!

4.

What means that two values are equal in Boolean?

a)

++

b)

==

c)

=

d)

>=

5.

Which means is not equal?

a)

=!

b)

||

c)

!=

d)

++!

6.

What is the result of the following?

9 % 2?

a)

1

b)

4.5

c)

7

d)

11

7.

What is missing? (fill in the blank)

_____(var i = 0; i < 5; i + +){

a)

if

b)

else

c)

for

d)

while

8.

Which is appropriate for a variable name?

a)

duke_Devils

b)

1Duke

c)

DUKE#1

d)

Duke Devils

9.

Which returns a random number between 1 and 55?

a)

randomInt(1, 55)

b)

randInt(1, 55)

c)

Randomizer.int(1, 55)

d)

Randomizer.netInt(1, 55)

10.

How many possible values can Randomizer.nextBoolean() return?

a)

0

b)

1

c)

2

d)

3

11.

How many possible values can Randomizer.nextBoolean() return?

a)

0

b)

1

c)

2

d)

3

12.

Which statement will end a loop?

a)

break

b)

else

c)

if

d)

if else

13.

Which is the correct way to obtain user input for a string?

a)

readLine()

b)

readInt()

c)

readDouble()

d)

readBoolean()

14.

You must use quotations around a prompt in a readLine().


Example:

readLine("What's your name?");

a)

True

b)

False

15.

What will this code segment output?

System.out.println("Hello");

System.out.println("World");

a)

Hello

World

b)

HelloWorld

c)

Hello World

d)

Hello


World

16.

What will this code segment output if the user inputs the number 10?


int yourInteger = readInt("Input a number");

System.out.println(yourInteger);

a)

yourInteger

b)

"yourInteger"

c)

10

d)

"10"

17.

His name is Fred and he is less than 16 years old

a)

if (name = "fred" && age < 16 )

b)

if (name === "fred" && age < 16 )

c)

if (name = "fred" || age < 16 )

d)

if (name === "fred" || age < 16 )

18.

Repeat something 10 times

a)

repeat 10

b)

for (var i = 0; i < 10; i + +)

c)

repeat { } until 10;

d)

while (i = 10)

19.

What is the symbol used for the INCREMENT operator in JS?

a)

+

b)

++

c)

=

d)

==

20.

Loops in programming start counting from ?

a)

0

b)

1

c)

Any number

d)

100

21.
Arithmetic Operators
What is ++ ?
a)
Modulo
b)
increment
c)
Decrement
d)
Addition
22.
Which one of the following is NOT a logical operator?
a)
||
b)
&&
c)
$$
d)
!
23.

Which of these is a loop?

a)

if(x < 10)

b)

while(x < 10)

c)

var x = 10;

d)

text (x,10; 10)

24.

Which of these will increase the value of the variable X?

a)

increment (x)

b)

x + +;

c)

x = x;

d)

x + 1;

25.
In JavaScript, which of the follow operand symbols means not equal to?
a)
<> 
b)
= # =
c)
!=
d)
##