1Z0-829 Working with Arrays and Collections Practice Question
Given: var list = List.of("A", "B", "C"); list.set(0, "Z"); What is the result?
⚠ Common exam trap
Test-takers frequently assume `List.of()` returns a mutable list similar to `new ArrayList<>()`, but it actually returns an immutable list, and the `set()` method will throw an `UnsupportedOperationException` at runtime.
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
✓
An UnsupportedOperationException is thrown
The `List.of()` method returns an immutable list, meaning its elements cannot be added, removed, or replaced. Calling `set()` on an immutable list throws an `UnsupportedOperationException` at runtime, which is why option B is correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
An ArrayIndexOutOfBoundsException is thrown
Why it's wrong here
Index is valid; exception type is different.
- ✓
An UnsupportedOperationException is thrown
Why this is correct
List.of returns an unmodifiable list.
- ✗
The code does not compile because var cannot be used with List.of
Why it's wrong here
var is allowed for local variables.
- ✗
The list is modified to [Z, B, C]
Why it's wrong here
Immutable list cannot be modified.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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-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.