Font size
WorksheetsCoding Diagnostic
Total questions: 28
Worksheet time: 53mins
A ______ statement ends the execution of a function, and returns control to the calling function
if/then
return
declaration
assignment
A _____ statement is used to declare a variable by specifying its data type and name
if/then
return
declaration
assignment
______ is a statement with a hypothesis followed by a conclusion
if/then
return
declaration
assignment
______ statement sets the current value of a variable, field, parameter, or element.
if/then
return
declaration
assignment
Convert the following number to decimal:
101
(a)
Convert the following number to decimal:
1110
(a)
Convert the following number to decimal:
100000
(a)
Convert the following number to decimal:
10110
(a)
Convert the following number to binary:
9
(a)
Convert the following number to binary:
6
(a)
Convert the following number to binary:
64
(a)
How many bits should you use to map efficiently 8 memory spaces
2
4
3
1
How many bits should you use to map efficiently 15 memory spaces
5
8
2
4
How many bits should you use to map efficiently 20 memory spaces
5
8
2
4
0 AND 0
0
1
1 AND 1
0
1
0 AND 1
0
1
1 AND 0
0
1
0 OR 0
0
1
1 OR 1
0
1
0 OR 1
0
1
1 OR 0
0
1
11001 + 11011
11011
110100
101001
101011
what is the 1's complement of 110110111011?
1001000100
110110000100
1010010011
11101110111
int a = 4;
int b = 2;
public boolean aIsBigger(int a, int b) {
if (a > b && (a - b) >= 2) { return true; }
else { return false; }
}
True
False
2
4
int a = 3;
int b = 2;
public boolean aIsBigger(int a, int b) {
if (a > b && (a - b) >= 2) { return true; }
else { return false; }
}
True
False
2
4
What does the following code do?
int count = 0;
for (int i=0; i<str.length(); i++) {
if (str.charAt(i) == 'e') count++;
}
count e
count letters in only the first half of the string
count letters except 'e'
All variables remain unchanged
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) {___________________________________}
