Questions and Answers - University of Maryland
1. int n = 5; int m = n++ + ++n; What is the value of m + ":" + n?
A. 13:7
B. 12:6
C. 12:7
D. 11:7
Answer: C. 12:7
Rationale: The left operand yields the old value and increments n. The right operand increments it
again before yielding.
2. An analyst needs to distinguish integer division and reference type. Which observations illustrate
them in that order?
A. Seven int units distributed in groups of three yields only two whole groups. / A String variable
can refer to a particular text object.
B. A String variable can refer to a particular text object. / Seven int units distributed in groups of
three yields only two whole groups.
C. A declared final limit is used instead of repeating a raw number. / A String variable can refer to a
particular text object.
D. Seven int units distributed in groups of three yields only two whole groups. / A menu uses a
number's remainder modulo two to test evenness.
Answer: A. Seven int units distributed in groups of three yields only two whole groups. / A String
variable can refer to a particular text object.
Rationale: Dividing two int values truncates the quotient toward zero if the divisor is nonzero. A
reference type represents references to objects or the null reference.
,3. Which pair of examples illustrates primitive type followed by assignment?
A. A second statement replaces the number stored in score. / A variable declaration uses int for
the number of seats.
B. A variable declaration uses int for the number of seats. / A menu uses a number's remainder
modulo two to test evenness.
C. A variable declaration uses int for the number of seats. / A second statement replaces the
number stored in score.
D. Seven int units distributed in groups of three yields only two whole groups. / A second
statement replaces the number stored in score.
Answer: C. A variable declaration uses int for the number of seats. / A second statement replaces the
number stored in score.
Rationale: A primitive type directly represents a fixed category of values such as int, double or
boolean. Assignment evaluates a value and stores it in the designated variable or location.
4. A menu uses a number's remainder modulo two to test evenness. Which course concept gives the
most specific explanation?
A. Precedence
B. Remainder operator
C. Identifier
D. Symbolic constant
Answer: B. Remainder operator
Rationale: The remainder operator reports the leftover from truncated division for integral
operands.
5. Which statement changes an already declared int score to 12?
A. score = 12;
B. Assign an int expression to a double variable
C. Integer division
D. boolean ready = true;
Answer: A. score = 12;
Rationale: Assignment evaluates a value and stores it in the designated variable or location.