Understanding Arrays.asList(): Fixed-Size List and Backing Array
Given: String[] array = {"A", "B"}; List<String> list = Arrays.asList(array); list.set(0, "C"); array[1] = "D"; What is the content of the list?
Quick Answer
The list ends up as [C, D] because Arrays.asList() does not copy the array into a new, independent list; it returns a fixed-size list view that is directly backed by the original array, meaning the list and the array are really two windows onto the exact same underlying storage. That is why calling list.set(0, 'C') does not just change the list, it writes through to the array itself, and conversely why assigning array[1] = 'D' directly on the array is immediately visible when you read the list afterward. Both operations are mutating the same backing storage, just accessed through two different references, so their effects accumulate rather than compete. This is the key trap in this kind of question: it is easy to assume a List created from an array behaves like an independent copy, the way many other list-construction patterns do, but Arrays.asList() explicitly does not work that way, and its fixed-size nature also means you cannot add or remove elements through the list, only replace existing ones with set(). Whenever a question shows an array being converted with Arrays.asList() and then shows mutations happening through both the array and the resulting list, expect every mutation, from either side, to be reflected in both, since they are simply two views of one shared array.
⚠ Common exam trap
The trap here is that candidates often forget that `Arrays.asList()` returns a list backed by the original array, so modifications through either reference are reflected in both, leading them to choose options that reflect only one of the two changes.
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
✓
[C, D]
`Arrays.asList()` returns a fixed-size list backed by the original array. Modifications to the list via `set()` directly affect the backing array, and modifications to the array elements are reflected in the list. After `list.set(0, "C")`, the first element of both the list and the array becomes "C". After `array[1] = "D"`, the second element of both becomes "D". Thus the list content is [C, D].
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
[A, D]
Why it's wrong here
set changed index 0 to C.
- ✓
[C, D]
Why this is correct
Both modifications affect the list.
- ✗
[A, B]
Why it's wrong here
Changes are applied.
- ✗
[C, B]
Why it's wrong here
Array modification changes list element too.
Go deeper
Related to this question
About these practice questions
This 1Z0-829 question is part of Courseiva's 513-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 →
Same concept, more angles
1 more way this is tested on 1Z0-829
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which of the following correctly converts an array of strings to a List?
easy- A.Collections.toList(array) converts the array.
- B.List.of(array) returns a mutable list.
- ✓ C.Arrays.asList(array) returns a fixed-size list backed by the array.
- D.Arrays.asList(array) returns a new ArrayList with a copy of the elements.
Why C: `Arrays.asList(array)` returns a fixed-size list backed by the original array, meaning changes to the list (like `set`) reflect in the array, but structural modifications (like `add` or `remove`) throw `UnsupportedOperationException`. This is the standard, exam-relevant way to convert an array to a List in Java.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 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-829 exam.