Advanced
Placement Computer Science Section 3 Quiz
On your answer sheet write down the letter of the answer that best answers the question. Do NOT write on this exam
Javadoc comments require that the comment begin with A) /** B) // C) /* D) ' E) none of the above
The following Java statement would create a new Vic object A) Vic a; B) new Vic(); C) malloc(sizeof(Vic)); D) public class Vic() {} E) none of the above
When you evaluate a portion of a boolean expression and the computer can figure out the answer before it is complete with the evaluation and thus skips evaluating the remainder of the expression, this situation is called A) cheating B) wait a second, no computer can be that dumb! C) short-circuit evaluation D) boolean quickening E) none of the above
A diagram which describes the interaction between various classes that compose a computer program by drawing boxes with lines and arrows connecting them to designate the interaction would include A) a OSI layer chart B) a Venn-Diagram C) Pie Chart D) UML diagram E) none of the above
The boolean value in Java defined that means something not-true is A) untrue B) false C) FALSE D) UNTRUE E) none of the above
A precondition is a comment that describes what must be true A) when the method is complete with its execution B) when the method is executing C) before the method executes D) always and forever E) none of the above
What must you include as the start of a method declaration in place of void in order for the method to evaluate to either true or false? A) int B) public C) private D) boolean E) none of the above
What command in the Java language allows you to selectively execute instructions or sets of instructions based on the boolean value of an expression? A) cond B) executeif C) && D) if E) ~
The boolean operator which returns true if and only if both expressions that surround it are true is A) || B) not C) ~ D) ! E) none of the above
The boolean operator that returns true if and only if the expression is false is A) ! B) not C) ~ D) || E) none of the above
For the following questions write on your answer sheet T if the statement is true, f otherwise
This statement can be considered a boolean statement
If the expression in an if statement is false the instructions that directly follow the else keyword are executed
Assuming you have a boolean variable declared called seabuscuit, the following will set seabuscuit to have a false value: seabuscuit = !true;
Assuming you have a Vic object assigned the variable ed, the following will reset the Vic object: ed.moveOn();
You can create boolean expressions that consist of several boolean expressions put together.
If you have the following line, Java will evaluate every part of the boolean expression in the if statement when it executes: if (true || false || (myVic.seesCD())) {
The following statements are based on the following section of code assuming a Vic sequence called fred defined as “1001” (a cd in slots 1 & 4)
if (fred.seesCD()) // line 1
fred.say(“CD1 found”); // line 2
else if (!fred.seesCD()) { // line 3
fred.moveOn(); // line 4
if (!fred.seesCD()) { // line 5
fred.say(“CD2 found”); // line 6
} // line 7
} // line 8
else // line 9
fred.say(“Can you hear me now?”); // line 10
} // line 11
Line 4 will be run if you execute the code
The if statement on line 3 is necessary in this code (ie: the result of the code will be different if it were removed)
Line 10 can never execute
CD2 Found will be displayed to the screen if you execute the code
Woohoo! Default! The two sweetest words in the English language!