Courseiva
Question 485 of 513
Working with Arrays and CollectionseasyMultiple ChoiceObjective-mapped

1Z0-829 Working with Arrays and Collections Practice Question

A developer is designing a method that returns an immutable list of strings from an array. Which approach best follows current Java best practices?

⚠ Common exam trap

It's easy for candidates to confuse `Arrays.asList()` (which returns a mutable, array-backed list) with an immutable list, or they think `Collections.unmodifiableList()` provides full immutability, but it only prevents modification through the returned reference while the underlying array remains mutable.

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

Return List.of(array)

`List.of(array)` returns an immutable list that is null-hostile and structurally immutable, as specified by the Java Platform Module System (JPMS) and the `List` interface since Java 9. This approach aligns with current best practices by providing a concise, safe, and predictable immutable collection without the overhead of wrapping or defensive copying.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Return new ArrayList<>(Arrays.asList(array))

    Why it's wrong here

    Returns a mutable list; not immutable.

  • Return Collections.unmodifiableList(Arrays.asList(array))

    Why it's wrong here

    This works but is verbose and still allows nulls; List.of is preferred.

  • Return Arrays.asList(array)

    Why it's wrong here

    Arrays.asList returns a fixed-size list that is mutable via set() and allows nulls, so it is not immutable.

  • Return List.of(array)

    Why this is correct

    List.of returns an immutable list, introduced in Java 9, and rejects nulls, making it the best practice.

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: Jul 4, 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-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.