CMSC Midterm 2 UPDATED ACTUAL
Questions and CORRECT Answers
remember to - CORRECT ANSWER - Write your name on each page of the exam
Which of the following are valid ways to declare a symbolic constant in Processing?
a. final float PI = 3.14;
b. float pi = 3.14;
c. final float pi = 3.14;
d. float PI = 3.14; - CORRECT ANSWER - a and c
Which of the following are false statements regarding symbolic constants in Processing?
a. Symbolic constant names must always be uppercase, or your program won't run
b. If you try to modify a symbolic constant, your program won't run
c. If you try to modify a symbolic constant, your program will give you a warning
d. It is highly recommended to use uppercase for symbolic constant names - CORRECT
ANSWER - a and c
Which of the following are true statements regarding arrays in Processing?
a. An array can contain data of multiple types (e.g. mix of int and float)
b. The largest legal index in an array is length - 1
,c. You are not allowed to have global array variables
d. It is possible to have an array of length 0
e. You can check whether two arrays a and b have the same contents using a == b - CORRECT
ANSWER - b and d
Which of the following are false statements regarding memory maps?
a. A memory map is a dynamic visual representation of the organization of data in a program
b. Each program has a unique memory map that is determined before the program begins
c. The memory map keeps changing as the program executes
d. Each function gets its own storage space in a memory map - CORRECT ANSWER - b
Which of the following are equal to 'C' in Processing? Note that the ASCII code for 'A' is 65 and
for 'a' is 97.
a. 'c'
b. (char) ('A' + 2)
c. (char) ('c' - ('a' - 'A'))
d. 99 - CORRECT ANSWER - b and c
,Which of the following are equal to "Hello123" in Processing?
a. "He" + "llo123"
b. "Hello" + 123
c. "Hello" + 12 + 3
d. "Hello" + (1 + 2 + 3) - CORRECT ANSWER - a and b and c
int [] arr = {1, 2, 3, 4, 5};
int i = 0, j = arr.length - 1;
while (i < j) {
int mystery = arr[i];
arr[i] = arr[j];
arr[j] = mystery;
i++;
j--;
}
println(arr);
What gets printed? - CORRECT ANSWER - 5, 4, 3, 2, 1
int x;
, void setup() {
x = 1;
}
void draw() {
int x = 2;
mystery(x);
println(x);
noLoop ();
}
void mystery(int y) {
y++;
x--;
// End of Example
} - CORRECT ANSWER - 2
int [] arr = {2, 4, 6, 8, 10, 12, 14, 16};
int x = 1;
for (int i = 1; i % 2 == 1; i += x) {
println(arr[i]);
x++;
}
What gets printed? - CORRECT ANSWER - 4
8
Questions and CORRECT Answers
remember to - CORRECT ANSWER - Write your name on each page of the exam
Which of the following are valid ways to declare a symbolic constant in Processing?
a. final float PI = 3.14;
b. float pi = 3.14;
c. final float pi = 3.14;
d. float PI = 3.14; - CORRECT ANSWER - a and c
Which of the following are false statements regarding symbolic constants in Processing?
a. Symbolic constant names must always be uppercase, or your program won't run
b. If you try to modify a symbolic constant, your program won't run
c. If you try to modify a symbolic constant, your program will give you a warning
d. It is highly recommended to use uppercase for symbolic constant names - CORRECT
ANSWER - a and c
Which of the following are true statements regarding arrays in Processing?
a. An array can contain data of multiple types (e.g. mix of int and float)
b. The largest legal index in an array is length - 1
,c. You are not allowed to have global array variables
d. It is possible to have an array of length 0
e. You can check whether two arrays a and b have the same contents using a == b - CORRECT
ANSWER - b and d
Which of the following are false statements regarding memory maps?
a. A memory map is a dynamic visual representation of the organization of data in a program
b. Each program has a unique memory map that is determined before the program begins
c. The memory map keeps changing as the program executes
d. Each function gets its own storage space in a memory map - CORRECT ANSWER - b
Which of the following are equal to 'C' in Processing? Note that the ASCII code for 'A' is 65 and
for 'a' is 97.
a. 'c'
b. (char) ('A' + 2)
c. (char) ('c' - ('a' - 'A'))
d. 99 - CORRECT ANSWER - b and c
,Which of the following are equal to "Hello123" in Processing?
a. "He" + "llo123"
b. "Hello" + 123
c. "Hello" + 12 + 3
d. "Hello" + (1 + 2 + 3) - CORRECT ANSWER - a and b and c
int [] arr = {1, 2, 3, 4, 5};
int i = 0, j = arr.length - 1;
while (i < j) {
int mystery = arr[i];
arr[i] = arr[j];
arr[j] = mystery;
i++;
j--;
}
println(arr);
What gets printed? - CORRECT ANSWER - 5, 4, 3, 2, 1
int x;
, void setup() {
x = 1;
}
void draw() {
int x = 2;
mystery(x);
println(x);
noLoop ();
}
void mystery(int y) {
y++;
x--;
// End of Example
} - CORRECT ANSWER - 2
int [] arr = {2, 4, 6, 8, 10, 12, 14, 16};
int x = 1;
for (int i = 1; i % 2 == 1; i += x) {
println(arr[i]);
x++;
}
What gets printed? - CORRECT ANSWER - 4
8