1Z0-811 Arrays and Methods Practice Question
What is the output of the following code? int[] a = {1,2,3}; int[] b = a; b[0] = 99; System.out.println(a[0]);
⚠ Common exam trap
Many exam-takers confuse reference assignment with copying the array contents, leading them to incorrectly believe that `b[0] = 99;` only affects `b` and not `a`.
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
✓
99
In Java, arrays are reference types. When `int[] b = a;` is executed, `b` does not create a new array; it simply references the same array object as `a`. Therefore, modifying `b[0]` directly changes the element in the original array `a`, so `a[0]` prints 99.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
0
Why it's wrong here
Default value not applicable.
- ✗
1
Why it's wrong here
The array is shared, so a[0] becomes 99.
- ✓
99
Why this is correct
a and b refer to same array.
- ✗
Compilation error
Why it's wrong here
Code compiles fine.
Go deeper
Related to this question
About these practice questions
This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.