Courseiva
Working with Arrays and CollectionsmediumMultiple ChoiceObjective-mapped

1Z0-829 Working with Arrays and Collections Practice Question

Consider: List<String> list = Arrays.asList("A", "B", "C"); list.add("D"); What is the result?

⚠ Common exam trap

Many candidates confuse `Arrays.asList()` with `new ArrayList<>(Arrays.asList(...))`, assuming the returned list is a regular mutable `ArrayList`, but the exam tests the fixed-size behavior of the wrapper list.

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 `Arrays.asList()` method returns a fixed-size list backed by the specified array. This list does not support structural modification operations like `add()` or `remove()`. Calling `add()` on such a list throws an `UnsupportedOperationException` at runtime.

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

    Exception type is UnsupportedOperationException.

  • The list becomes [A, B, C, D]

    Why it's wrong here

    Cannot add element to fixed-size list.

  • A ClassCastException is thrown

    Why it's wrong here

    No casting issue.

  • An UnsupportedOperationException is thrown

    Why this is correct

    Arrays.asList returns fixed-size list.

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 →

How Courseiva writes practice questions · Editorial policy

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.