1Z0-803 · Question #115
Given: What is the result?
The correct answer is B. 11, 21, 31, 12, 22, 32. The result 11, 21, 31, 12, 22, 32 implies that an initial set of values (e.g., 10, 20, 30) was first processed and each incremented by one, then these original values were themselves incremented, and finally processed again with an additional increment of one.
Question
Given:
What is the result?
Exhibit
Options
- A11, 21, 31, 11, 21, 31
- B11, 21, 31, 12, 22, 32
- C12, 22, 32, 12, 22, 32
- D10, 20, 30, 10, 20, 30
How the community answered
(62 responses)- A10% (6)
- B71% (44)
- C5% (3)
- D15% (9)
Why each option
The result 11, 21, 31, 12, 22, 32 implies that an initial set of values (e.g., 10, 20, 30) was first processed and each incremented by one, then these original values were themselves incremented, and finally processed again with an additional increment of one.
A is incorrect because it implies the array elements or state did not change between two distinct printing operations.
B is correct because it reflects a two-phase process. In the first phase, elements from an initial set (e.g., 10, 20, 30) are printed after being incremented by one (resulting in 11, 21, 31). In the second phase, the original elements are first permanently incremented (becoming 11, 21, 31), and then these new values are again printed after being incremented by one (resulting in 12, 22, 32). This behavior is common with loops that first read and then modify array contents.
C is incorrect because it suggests all elements were effectively incremented twice before the first print sequence.
D is incorrect because it implies no increment operation occurred on the values during printing.
Concept tested: Array iteration and element modification
Source: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
Topics
Community Discussion
No community discussion yet for this question.
