nerdexam
Oracle

1Z0-808 · Question #19

int[] intArr = {15, 30, 45, 60, 75}; intArr[2] = intArr[4]; intArr[4] = 90; What are the values of each element in intArr after this code has executed?

The correct answer is C. 15, 30, 75, 60, 90. Option C is correct because the code executes two sequential operations: first, intArr[2] = intArr[4] copies the value at index 4 (which is 75) into index 2, giving {15, 30, 75, 60, 75}; then intArr[4] = 90 overwrites index 4 with 90, yielding the final result {15, 30, 75, 60…

Creating and Using Arrays

Question

int[] intArr = {15, 30, 45, 60, 75}; intArr[2] = intArr[4]; intArr[4] = 90; What are the values of each element in intArr after this code has executed?

Options

  • A15, 60, 45, 90, 75
  • B15, 90, 45, 90, 75
  • C15, 30, 75, 60, 90
  • D15,30,90, 60, 90
  • E15, 4, 45, 60, 90

How the community answered

(47 responses)
  • A
    11% (5)
  • B
    4% (2)
  • C
    83% (39)
  • D
    2% (1)

Explanation

Option C is correct because the code executes two sequential operations: first, intArr[2] = intArr[4] copies the value at index 4 (which is 75) into index 2, giving {15, 30, 75, 60, 75}; then intArr[4] = 90 overwrites index 4 with 90, yielding the final result {15, 30, 75, 60, 90}.

  • A is wrong because index 1 was never modified - it stays 30, not 60.
  • B is wrong for the same reason (index 1 unchanged), and also misplaces 90 at index 1.
  • D is the most tempting distractor: it puts 90 at index 2, which would only be correct if the two lines were reversed - it confuses the order of execution.
  • E is wrong because it substitutes the index number (4) as a value at index 1, a classic confusion between an index and its contents.

Memory tip: Read array assignments right-to-left like math - the value on the right side is captured at that moment, so trace the array state line by line and never assume a later assignment retroactively changes an earlier copy.

Topics

#array indexing#array assignment#variable assignment#array initialization

Community Discussion

No community discussion yet for this question.

Full 1Z0-808 Practice