1Z0-829 Working with Arrays and Collections Practice Question
Which of the following will compile without error and produce an unmodifiable list containing three elements?
⚠ Common exam trap
Watch out — candidates often confuse `Arrays.asList()` with an unmodifiable list, not realizing that `set()` is still permitted, while `List.of()` is truly immutable and the correct choice for an unmodifiable list in modern Java.
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
✓
List.of("A","B","C")
`List.of("A","B","C")` returns an unmodifiable list exactly as required. In Java 9+, `List.of` returns an immutable list; any attempt to modify it throws `UnsupportedOperationException`. Option A, `Arrays.asList`, returns a fixed-size list backed by an array that allows modification via `set()`, so it is not unmodifiable. Option B, `new ArrayList<>(List.of(...))`, creates a mutable ArrayList. Option D, `Collections.unmodifiableList`, returns an unmodifiable view, but the underlying ArrayList is still mutable; modifications to the original list affect the view, so it does not guarantee immutability. Therefore, only C meets the criteria.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Arrays.asList("A","B","C")
Why it's wrong here
Incorrect: this returns a fixed-size but mutable list.
- ✗
new ArrayList<>(List.of("A","B","C"))
Why it's wrong here
Incorrect: this creates a mutable list.
- ✓
List.of("A","B","C")
Why this is correct
Correct: List.of returns an immutable list.
- ✗
Collections.unmodifiableList(new ArrayList<>(List.of("A","B","C")))
Why it's wrong here
Incorrect: while the wrapper prevents direct modification, the backing list can still be changed via other references, so it is not immutable.
- ✗
None of the above
Why it's wrong here
Incorrect: List.of works.
Go deeper
Related to this question
About these practice questions
One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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-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.