Question 421
int n = 6;
n += n * 2;
n -= n / 4;
System.out.println(n);
What is printed when the code segment executes?Main Solution
Answer
Answer: D. Start n = 6. First, n += n * 2 evaluates the right-hand side using the current n: 6 * 2 = 12, then n = 6 + 12 = 18. Second, n -= n / 4 with n = 18: 18 / 4 = 4 (integer division), then n = 18 - 4 = 14.
Answer: Correct: D
Answer images

