Courseiva
Arrays and MethodsmediumMultiple ChoiceObjective-mapped

1Z0-811 Arrays and Methods Practice Question

Given the code:

int[] a = {1, 2, 3}; int[] b = {4, 5}; a = b; b[0] = 99; System.out.println(a[0]);

What is the output?

⚠ Common exam trap

The trap here is that candidates mistakenly think `a = b` copies the array values, leading them to believe `a[0]` retains its original value of 1 or that the arrays remain independent.

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

After `a = b;`, both `a` and `b` reference the same array object. Modifying `b[0]` to 99 also changes `a[0]` because they share the same underlying array. Therefore, `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.

  • 3

    Why it's wrong here

    3 is from the original array a, but a no longer references that array.

  • 1

    Why it's wrong here

    1 was the value before reassignment, but a now references the array b.

  • 99

    Why this is correct

    After the assignment a = b, both references point to the same array; changing b[0] to 99 changes the shared array, so a[0] is 99.

  • 4

    Why it's wrong here

    4 was the original b[0] before it was changed to 99.

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 →

How Courseiva writes practice questions · Editorial policy

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.