1Z0-830 · Domain 5 of 10

1Z0-830 Domain 5: Working with Arrays and Collections

This section covers storing and organizing data in Java 21: creating and copying arrays, using List, Set, Map and Deque implementations, adding, removing, updating and retrieving elements, and sorting with Comparable and Comparator.

Exam weight estimate
Not published
Official objectives estimate
1
Estimated questions estimate
~5
Suggested study time estimate
6–8 hrs

About 10 min read Reviewed October 2026

Overview

Domain 5 is one broad objective: create arrays and List, Set, Map and Deque collections, then add, remove, update, retrieve and sort their elements. That covers array declaration and the Arrays utility class, the main implementations such as ArrayList, LinkedList, HashSet, TreeSet, HashMap, TreeMap and ArrayDeque, and the factory methods List.of, Set.of and Map.of that return unmodifiable collections.

Java 21 adds sequenced collections, giving List, Deque, LinkedHashSet and sorted sets common methods such as getFirst, getLast, addFirst and reversed. Sorting brings in Comparable, Comparator and its chaining methods. Exam questions mostly show a few operations on a collection and ask for the printed result or the exception thrown.

How it's tested

Most questions show a short sequence of collection operations and ask for the final contents, a returned value, or the exception thrown. Others ask which implementation meets a requirement such as sorted order, uniqueness or fast insertion at both ends. Watch the method overload being called and whether the collection is modifiable.

  • Final contents

    A list, set, map or deque goes through several add, remove and put calls, and you choose the printed result.

  • Unmodifiable or fixed-size

    Code modifies a collection created by List.of, Map.of or Arrays.asList, and you decide whether it succeeds or throws.

  • Sort order

    Elements are sorted with natural order or a chained Comparator, and you pick the resulting sequence.

Reasoning it through

Code calls Arrays.asList on a String array, sets element 0 to a new value, and then calls add on the list. The set call succeeds and also changes the underlying array, because the list is a fixed-size view backed by it. The add call throws UnsupportedOperationException because the size cannot change. List.of would have rejected the set call too.

Objectives 1

Official objectives from the Oracle outline, in outline order.

5.1 Create arrays, List, Set, Map and Deque collections, and add, remove, update, retrieve and sort their elements.Arrays, core collection interfaces and implementations, factories, mutation methods and sorting.
What it means
Arrays are fixed-length, typed containers indexed from zero. The collections framework adds resizable structures: List keeps order and allows duplicates, Set rejects duplicates, Map stores key-value pairs with unique keys, and Deque supports insertion and removal at both ends. You must create each one, change its contents and sort it.
What to understand
Know array declaration forms, default element values, length as a field, and Arrays methods such as sort, binarySearch (only reliable on sorted arrays, returning a negative insertion point when absent), fill, equals, compare and mismatch. List.of, Set.of and Map.of return unmodifiable collections that reject null, and Set.of or Map.of throw IllegalArgumentException on duplicates. HashMap allows one null key, TreeMap does not with natural ordering. Map methods to know include put, putIfAbsent, getOrDefault, merge, computeIfAbsent and entrySet. For Deque, push, pop and peek work at the head as a stack, while offer and poll give queue behaviour. Sequenced collections add getFirst, getLast and reversed. Sort with Collections.sort, List.sort, or Comparator.comparing combined with thenComparing and reversed.
How it shows up
Expect remove by index versus by value, modifications of unmodifiable lists, TreeSet ordering and Deque stack operations.
Common confusion
Thinking List.of returns an ArrayList, or that a TreeSet keeps two elements its comparator considers equal.

High-yield concepts

The terms, rules and formulas this domain turns into questions most often.

  • remove(int) versus remove(Object)

    List overloads that remove by index or by value.

    Remember
    An int argument removes by position.
    Tested as
    Final contents questions.
    Trap
    Expecting list.remove(1) to remove the value 1.
  • Unmodifiable factories

    List.of, Set.of and Map.of.

    Remember
    No changes, no nulls.
    Tested as
    Exception questions.
    Trap
    Expecting add to work.
  • Arrays.asList

    Fixed-size list backed by an array.

    Remember
    set works and writes through; add and remove throw.
    Tested as
    Mixed modification questions.
    Trap
    Treating it like an ArrayList.
  • TreeSet and TreeMap

    Sorted structures using compareTo or a Comparator.

    Remember
    Equal comparison means duplicate.
    Tested as
    Ordering and uniqueness.
    Trap
    Adding objects that are not Comparable.
  • HashMap

    Unordered map with fast lookup.

    Remember
    One null key allowed; iteration order unspecified.
    Tested as
    Map behaviour questions.
    Trap
    Relying on insertion order.
  • Deque as stack

    push and pop act on the head.

    Remember
    peek reads without removing.
    Tested as
    Stack output questions.
    Trap
    Expecting pop to take from the tail.
  • Sequenced collections

    Java 21 interfaces with first and last access.

    Remember
    getFirst, getLast, addFirst, reversed.
    Tested as
    Java 21 API questions.
    Trap
    Assuming HashSet is sequenced.
  • Comparator chaining

    comparing, thenComparing and reversed build sort orders.

    Remember
    reversed applies to the whole chain built so far.
    Tested as
    Sort result questions.
    Trap
    Placing reversed in the wrong position.
  • Arrays.binarySearch

    Searches a sorted array.

    Remember
    Missing values return -(insertion point) - 1.
    Tested as
    Return value questions.
    Trap
    Searching an unsorted array and trusting the result.
  • Map.merge

    Combines a new value with an existing one.

    Remember
    Inserts the value when the key is absent.
    Tested as
    Word count style questions.
    Trap
    Expecting the function to run for a new key.

Side by side

Concepts candidates mix up, compared on the point that decides the answer.

Collection types

ConceptMeaningKey differenceCommon trap
List Ordered sequence allowing duplicates Index-based access Confusing remove overloads
Set Collection without duplicates Uniqueness by equals or compareTo Expecting insertion order from HashSet
Map Unique keys mapped to values Not a Collection subtype Iterating it directly in an enhanced for
Deque Double-ended queue Stack and queue operations at both ends Adding null to ArrayDeque

Ways to create a list

ConceptMeaningKey differenceCommon trap
new ArrayList<>() Resizable and fully modifiable Allows nulls and duplicates Assuming it is thread-safe
List.of(...) Unmodifiable list Rejects nulls; any change throws Calling set or add
Arrays.asList(...) Fixed-size view of an array set writes through; add and remove throw Expecting independence from the array
List.copyOf(...) Unmodifiable copy of a collection Snapshot not affected by later changes Copying a collection that contains null

Exam traps

Each trap is an answer that looks right. Learn the clue that should change your mind.

  1. Remove by value

    What candidates pick
    Expects list.remove(1) on [10, 20, 30] to leave the list unchanged.
    Why it looks right
    The value 1 is not in the list.
    Why it's wrong
    With an int argument, the remove(int index) overload is chosen, so the element at index 1 is removed.

    Clue to watch for A List<Integer> with remove called on an int literal.

  2. Modifiable factory

    What candidates pick
    Assumes List.of returns an ArrayList that accepts add.
    Why it looks right
    Most list examples use ArrayList.
    Why it's wrong
    List.of returns an unmodifiable list, so add, remove and set throw UnsupportedOperationException.

    Clue to watch for A collection built with of() and then modified.

  3. asList independence

    What candidates pick
    Expects changes to the list not to affect the array.
    Why it looks right
    A new list object appears to be created.
    Why it's wrong
    Arrays.asList returns a view backed by the array, so set on the list changes the array and vice versa.

    Clue to watch for Both the array and the list are printed after a set call.

  4. TreeSet keeps both

    What candidates pick
    Counts two elements that compare as equal as separate entries.
    Why it looks right
    equals would say they differ.
    Why it's wrong
    TreeSet decides duplicates with compareTo or its Comparator, so the second element is dropped.

    Clue to watch for A comparator comparing only one field, such as length.

  5. Stack from the tail

    What candidates pick
    Predicts pop removes the last element added with add.
    Why it looks right
    Queue habits suggest tail removal.
    Why it's wrong
    pop removes from the head; push adds at the head, so stack operations should use push, not add.

    Clue to watch for A Deque mixing add and push calls.

Answer framework

Use this sequence for any question built on arrays or collections.

  1. Identify the exact implementation or factory used, since it decides modifiability, null handling, ordering and duplicate rules.
  2. For each method call, determine which overload applies, especially remove(int) versus remove(Object) on a List of Integer values.
  3. Track the contents after every operation, noting where a Deque adds or removes and whether a Map call replaces, merges or ignores a value.
  4. Check whether any operation throws: UnsupportedOperationException on unmodifiable collections, NullPointerException on factories, or IndexOutOfBoundsException on bad indexes.
  5. Apply ordering last: natural order or Comparator chain for sorted types, insertion order for lists and linked types, and no guarantee for hash types.

Practice question

An inventory service adjusts a list of stock counts. What does this code print? List<Integer> list = new ArrayList<>(List.of(10, 20, 30, 40)); list.remove(1); list.remove(Integer.valueOf(30)); list.add(1, 5); System.out.println(list);

Choose one answer

Want more like this? The 1Z0-830 practice test has questions for every domain.

Checklist

0 of 10

Tick each one you can do without notes. Your ticks stay in this browser.

Study strategy

Collections are best learned at a keyboard. Create one class per structure and run short sequences of operations, printing after each step. For lists, compare remove(int) with remove(Object), then repeat the same calls on List.of and Arrays.asList results to see which throw. For maps, practise put, putIfAbsent, merge and computeIfAbsent on a word-count example.

Next, work through ordering. Add the same elements to HashSet, LinkedHashSet and TreeSet and compare the printed order. Sort a list of records with Comparator.comparing, thenComparing and reversed, moving reversed to different positions in the chain to see the effect. Try the Java 21 sequenced methods on a list and a deque, and note that reversed returns a view rather than a sorted copy.

Finish with arrays: declaration forms, default values, Arrays.sort, binarySearch with missing values, and Arrays.compare. Summarise every exception rule on one page, then answer timed practice items where you write the final contents before looking at the options.

FAQ

How much of 1Z0-830 is Domain 5, Working with Arrays and Collections?

No official weight exists for the arrays and collections section. It is one objective, and we plan for about five questions, with collections also appearing in stream and concurrency items.

Are generics tested on their own?

Generics appear inside collection declarations and method signatures, such as wildcards in Comparator parameters, but the objective centres on using collections rather than writing generic types.

Do I need to know sequenced collections?

They were added in Java 21, so expect methods such as getFirst, getLast, addFirst and reversed on lists, deques and linked or sorted sets.

Can a HashMap hold a null key?

Yes, one null key and any number of null values. Map.of and TreeMap with natural ordering reject null keys.

What does Arrays.compare return?

A negative number, zero or a positive number based on lexicographic comparison of the two arrays, with a shorter prefix array sorting first.

Is ArrayDeque better than Stack?

For stack behaviour Java recommends Deque implementations such as ArrayDeque over the legacy Stack class. Note that ArrayDeque does not accept null elements.

Test your Domain 5 knowledge

You have reviewed arrays, List, Set, Map and Deque operations, unmodifiable factories, sequenced collections and sorting. Check whether you can predict contents after a sequence of calls.

Keep going