Programming, Object-Oriented Programming, Arrays,
ArrayLists, Inheritance, Algorithms, FRQ Practice &
Multiple-Choice Exam Review
Question 1: What is the result of the expression 17 % 3 in Java?
A. 5
B. 2
C. 1
D. 0
CORRECT ANSWER: B. 2
Rationale: The modulo operator (%) returns the remainder of division,
and 17 divided by 3 is 5 with a remainder of 2.
Question 2: What is the value of the integer variable x after the
statement int x = ; is executed?
A. 3.75
B. 3
C. 4
D. 3.0
CORRECT ANSWER: B. 3
Rationale: Integer division in Java truncates the decimal portion, so 15
divided by 4 evaluates to 3.
Question 3: What is the value of the double variable y after double y =
; is executed?
A. 3.75
B. 3.0
,C. 4.0
D. 3
CORRECT ANSWER: B. 3.0
Rationale: Because both 15 and 4 are integers, integer division occurs
first resulting in 3, which is then implicitly cast to the double value 3.0.
Question 4: What is the value of z after double z = (double) ; is
executed?
A. 3.75
B. 3.0
C. 4.0
D. 3
CORRECT ANSWER: A. 3.75
Rationale: The cast (double) applies only to 15, making it 15.0, so
floating-point division occurs, resulting in 3.75.
Question 5: What is the value of x after int x = 5; x = x + 2.5; is
executed?
A. 7.5
B. 7
C. 8
D. A compile-time error occurs.
CORRECT ANSWER: D. A compile-time error occurs.
Rationale: Java does not allow implicit narrowing conversions; assigning
a double (7.5) to an int variable requires an explicit cast.
,Question 6: What is printed by System.out.println(5 + 3 + "Hello");?
A. 53Hello
B. 8Hello
C. Hello8
D. A compile-time error occurs.
CORRECT ANSWER: B. 8Hello
Rationale: Addition is evaluated left-to-right; 5 + 3 is 8, and then 8 is
concatenated with the string "Hello".
Question 7: What is printed by System.out.println("Hello" + 5 + 3);?
A. Hello8
B. Hello53
C. 8Hello
D. A compile-time error occurs.
CORRECT ANSWER: B. Hello53
Rationale: String concatenation occurs left-to-right; "Hello" + 5
becomes "Hello5", which is then concatenated with 3 to become
"Hello53".
Question 8: What is the value of x after int x = 4; x++;
System.out.println(x++);?
A. 4
B. 5
C. 6
D. 7
,CORRECT ANSWER: B. 5
Rationale: The first x++ increments x to 5, and the second x++ prints the
current value 5 before incrementing x to 6.
Question 9: What is the value of x after int x = 4; ++x;
System.out.println(++x);?
A. 4
B. 5
C. 6
D. 7
CORRECT ANSWER: C. 6
Rationale: The first ++x increments x to 5, and the second ++x
increments x to 6 and then prints 6.
*Question 10: What is the value of x after int x = 10; x = 2 + 3;?
A. 50
B. 23
C. 26
D. 15
CORRECT ANSWER: B. 23
Rationale: The right side of a compound assignment operator is
evaluated first, so 2 + 3 is 5, and 10 * 5 is 50. Wait, 10 * 5 is 50. Let me
correct the options.
*Question 10: What is the value of x after int x = 10; x = 2 + 3;?
A. 50