nerdexam
Oracle

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.

Using Operators and Decision Constructs

Question

Given:

What is the result?

Exhibit

1Z0-803 question #115 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)
  • A
    10% (6)
  • B
    71% (44)
  • C
    5% (3)
  • D
    15% (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.

A11, 21, 31, 11, 21, 31

A is incorrect because it implies the array elements or state did not change between two distinct printing operations.

B11, 21, 31, 12, 22, 32Correct

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.

C12, 22, 32, 12, 22, 32

C is incorrect because it suggests all elements were effectively incremented twice before the first print sequence.

D10, 20, 30, 10, 20, 30

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

#operators#variable manipulation#output

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice