Question 424 of 481
1Z0-811 Arrays and Methods Practice Question
Given the method: public static void modify(int[] data) { data = new int[]{10,20}; } What is the output of: int[] vals = {1,2}; modify(vals); System.out.println(vals[0]);
⚠ Common exam trap
Candidates often confuse reassigning a reference with modifying the object's contents, leading them to incorrectly believe the original array is replaced.
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
✓
1
In Java, when an object reference (including an array) is passed to a method, the reference itself is passed by value. Inside `modify`, the assignment `data = new int[]{10,20}` reassigns the local variable `data` to a new array object, but this does not affect the original reference `vals` in the caller. Therefore, `vals[0]` remains `1`, making option C correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
10
Why it's wrong here
Incorrect because the method does not modify elements; it reassigns the reference.
- ✗
Compilation error
Why it's wrong here
The code compiles and runs.
- ✓
1
Why this is correct
Correct: the original array is unchanged.
- ✗
0
Why it's wrong here
No default initialization occurs; the array was initialized with {1,2}.
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 →
Last reviewed: Jun 25, 2026
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.
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.
Sign in to join the discussion.