Courseiva
Question 425 of 481
Arrays and MethodsmediumMultiple ChoiceObjective-mapped

1Z0-811 Arrays and Methods Practice Question

Exhibit

Refer to the exhibit.
public class ArrayTest {
    public static void main(String[] args) {
        int[] arr = new int[3];
        arr[0] = 5;
        arr[1] = 10;
        arr[2] = 15;
        modify(arr);
        System.out.println(arr[0]);
    }
    public static void modify(int[] a) {
        a = new int[3];
        a[0] = 100;
    }
}

What is printed when the main method runs?

⚠ Common exam trap

Oracle often tests the distinction between modifying an object's state (which affects the caller) versus reassigning the reference (which does not), and the trap here is that candidates mistakenly think reassigning the parameter changes the original array, leading them to choose option D.

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

5

The method `modifyArray` receives a reference to the array, and the assignment `arr = new int[]{100};` changes the local reference `arr` to point to a new array object. The original array in `main` remains unchanged, so `arr[0]` still prints 5. Java passes object references by value, meaning the reference itself is copied, and reassigning the local reference does not affect the caller's reference.

Answer analysis

Option-by-option breakdown

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

  • 5

    Why this is correct

    The original array is not modified; the method reassigned the reference.

  • 0

    Why it's wrong here

    Not the initial value.

  • Compilation error: cannot assign new array to parameter

    Why it's wrong here

    Parameters can be reassigned inside the method.

  • 100

    Why it's wrong here

    The modification applies to the new local array, not the 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 30, 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.