Working with Arrays and Collections
The exam checks array semantics, which collection fits which job, and the mutability rules of factory methods.
Arrays
new int[3] is zero-filled; int[] a = {1,2}; is allowed only in a declaration, otherwise new int[]{1,2}. Multidimensional arrays are arrays of arrays, so new int[3][] has three null elements. Arrays.equals compares contents one level deep, Arrays.deepEquals recurses. Arrays.binarySearch requires a sorted array and returns -(insertionPoint) - 1 when the value is absent. Arrays.asList on a primitive array produces a one-element List<int[]>, not a list of ints.
Choosing a collection
List keeps order and allows duplicates (ArrayList for random access, LinkedList for cheap head insertion). Set rejects duplicates: HashSet unordered, LinkedHashSet insertion-ordered, TreeSet sorted. Map mirrors this with HashMap, LinkedHashMap and TreeMap. ArrayDeque is the usual Queue/Deque; PriorityQueue orders by Comparable or Comparator and its iterator does not return sorted order. TreeSet and TreeMap need a consistent comparison; HashMap needs consistent equals and hashCode.
Immutability and iteration
List.of, Set.of and Map.of return truly immutable collections that reject nulls and throw UnsupportedOperationException on modification. Arrays.asList is fixed-size: set works, add and remove do not. Collections.unmodifiableList is a live view. Removing from a collection inside an enhanced for throws ConcurrentModificationException; use iterator.remove() or removeIf.
Worked example
Arrays.binarySearch(new int[]{10,20,30,40}, 25) returns -3, because the insertion point is index 2 and the formula is -(2)-1.
Traps
Assuming TreeSet uses equals rather than compareTo; adding null to a natural-ordering TreeMap (NullPointerException); expecting HashMap iteration order to be stable.