wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Coding Diagnostic

Total questions: 28

Worksheet time: 53mins

Name
Class
Date
1.

A ______ statement ends the execution of a function, and returns control to the calling function

a)

if/then

b)

return

c)

declaration

d)

assignment

2.

A _____ statement is used to declare a variable by specifying its data type and name

a)

if/then

b)

return

c)

declaration

d)

assignment

3.

______ is a statement with a hypothesis followed by a conclusion

a)

if/then

b)

return

c)

declaration

d)

assignment

4.

______ statement sets the current value of a variable, field, parameter, or element.

a)

if/then

b)

return

c)

declaration

d)

assignment

5.

Convert the following number to decimal:

101

(a)  

6.

Convert the following number to decimal:

1110

(a)  

7.

Convert the following number to decimal:

100000

(a)  

8.

Convert the following number to decimal:

10110

(a)  

9.

Convert the following number to binary:

9

(a)  

10.

Convert the following number to binary:

6

(a)  

11.

Convert the following number to binary:

64

(a)  

12.

How many bits should you use to map efficiently 8 memory spaces

a)

2

b)

4

c)

3

d)

1

13.

How many bits should you use to map efficiently 15 memory spaces

a)

5

b)

8

c)

2

d)

4

14.

How many bits should you use to map efficiently 20 memory spaces

a)

5

b)

8

c)

2

d)

4

15.

0 AND 0

a)

0

b)

1

16.

1 AND 1

a)

0

b)

1

17.

0 AND 1

a)

0

b)

1

18.

1 AND 0

a)

0

b)

1

19.

0 OR 0

a)

0

b)

1

20.

1 OR 1

a)

0

b)

1

21.

0 OR 1

a)

0

b)

1

22.

1 OR 0

a)

0

b)

1

23.

11001 + 11011

a)

11011

b)

110100

c)

101001

d)

101011

24.

what is the 1's complement of 110110111011?

a)

1001000100

b)

110110000100

c)

1010010011

d)

11101110111

25.

int a = 4;

int b = 2;

public boolean aIsBigger(int a, int b) {

if (a > b && (a - b) >= 2) { return true; }

else { return false; }

}

a)

True

b)

False

c)

2

d)

4

26.

int a = 3;

int b = 2;

public boolean aIsBigger(int a, int b) {

if (a > b && (a - b) >= 2) { return true; }

else { return false; }

}

a)

True

b)

False

c)

2

d)

4

27.

What does the following code do?

int count = 0;

for (int i=0; i<str.length(); i++) {

if (str.charAt(i) == 'e') count++;

}

a)

count e

b)

count letters in only the first half of the string

c)

count letters except 'e'

d)

All variables remain unchanged

28.

We have bunnies standing in a line, numbered 1, 2, ... The odd bunnies (1, 3, ..) have the normal 2 ears. The even bunnies (2, 4, ..) we'll say have 3 ears, because they each have a raised foot. Recursively return the number of "ears" in the bunny line 1, 2, ... n (without loops or multiplication).

bunnyEars2(0) → 0

bunnyEars2(1) → 2

bunnyEars2(2) → 5

public int bunnyEars2(int bunnies) {___________________________________}

4 lines