Courseiva
Question 149 of 481
Arrays and MethodsmediumMultiple SelectObjective-mapped

1Z0-811 Arrays and Methods Practice Question

Which TWO methods correctly modify the passed array in place?

⚠ Common exam trap

The 1Z0-811 exam often tests the misconception that reassigning the method parameter (e.g., a = new int[10]) modifies the original array, when in fact it only changes the local reference, leaving the original array untouched.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

public void zeroOut(int[] a) { for (int i = 0; i < a.length; i++) a[i] = 0; }

It directly modifies each element of the passed array by assigning 0 to a[i] within the loop. In Java, when an array is passed to a method, the method receives a reference to the same array object, so changes to the array's elements are reflected in the caller's array.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • public void zeroOut(int[] a) { for (int i = 0; i < a.length; i++) a[i] = 0; }

    Why this is correct

    Sets each element to 0, modifying the original array.

  • public void incrementEach(int[] a) { for (int i = 0; i < a.length; i++) a[i]++; }

    Why this is correct

    Modifies each element in place.

  • public void reset(int[] a) { a = new int[10]; }

    Why it's wrong here

    Creates a new array local to the method; original unchanged.

  • public void swap(int[] a) { int[] temp = a; a = new int[1]; a[0] = temp[0]; }

    Why it's wrong here

    Reassigns the reference; original array unchanged.

  • public void setFirst(int[][] a) { a = new int[1][1]; a[0][0] = 5; }

    Why it's wrong here

    Reassigns the reference, not modifying original.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 25, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.