Question 496 of 509
Arrays and MethodseasyMultiple ChoiceObjective-mapped

Quick Answer

The answer is 99 because in Java, arrays are reference types, so the assignment `int[] b = a` does not create a copy of the array; instead, `b` holds a reference to the same array object as `a`. This means any modification through `b`, such as `b[0] = 99`, directly alters the underlying array, and `a[0]` reflects that change. On the Oracle Java Foundations 1Z0-811 exam, this concept tests your understanding of reference copy versus value copy, often appearing in questions about array manipulation and object aliasing. A common trap is assuming `b = a` creates a separate array, leading to incorrect answers like 1. To avoid this, remember the memory tip: "Arrays are objects—assignment shares the key, not the house." When you see an array reference copy, think of two variables pointing to the same data in heap memory; any change through one reference is visible through the other.

1Z0-811 Arrays and Methods Practice Question

This 1Z0-811 practice question tests your understanding of arrays and methods. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

What is the output of the following code? int[] a = {1,2,3}; int[] b = a; b[0] = 99; System.out.println(a[0]);

Question 1easymultiple choice
Full question →

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

Option C is correct because 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.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

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.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Compilation error

    Why it's wrong here

    Code compiles fine.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates often confuse reference assignment with copying the array contents, leading them to incorrectly believe that `b[0] = 99;` only affects `b` and not `a`.

Detailed technical explanation

How to think about this question

In Java, arrays are objects stored on the heap, and variables hold references (memory addresses) to those objects. The assignment `int[] b = a;` copies the reference, not the array contents, so both `a` and `b` point to the same array object. This behavior is fundamental to understanding aliasing and mutable objects in Java, and it is critical when passing arrays to methods to avoid unintended side effects.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A practitioner preparing for the 1Z0-811 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related 1Z0-811 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free 1Z0-811 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this 1Z0-811 question test?

Arrays and Methods — This question tests Arrays and Methods — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: 99 — Option C is correct because 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.

What should I do if I get this 1Z0-811 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

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 11, 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.