20+ practice questions focused on Working with Arrays and Collections — one of the most tested topics on the Oracle Certified Professional Java SE 17 Developer 1Z0-829 exam. Each question includes a detailed explanation so you learn why the right answer is correct.
Start Working with Arrays and Collections PracticeA developer needs to remove elements from an ArrayList<String> while iterating over it. Which approach is safest and avoids ConcurrentModificationException?
Explanation: Option C is correct because the Iterator's remove() method is the only safe way to remove elements from a collection while iterating, as it updates both the iterator's internal cursor and the collection's modCount, preventing ConcurrentModificationException. The enhanced for-each loop (options A and D) uses an implicit iterator that does not expose a remove method, so calling list.remove() directly modifies the collection without updating the iterator's state, causing the exception. Option B avoids the exception by using an index-based loop, but it is unsafe because removing an element shifts subsequent elements left, causing the loop to skip the next element and potentially miss removals or throw an IndexOutOfBoundsException.
Given: HashSet<String> set = new HashSet<>(); set.add("A"); set.add("B"); set.add("C"); set.add("A"); System.out.println(set.size()); What is the output?
Explanation: Option B is correct because HashSet does not allow duplicate elements. When adding "A" twice, the second add is ignored, so the set contains only three unique elements: "A", "B", and "C". Therefore, set.size() returns 3.
Which interface provides the ability to store key-value pairs and allows null keys?
Explanation: HashMap is the correct answer because it implements the Map interface, allows null keys (only one null key is permitted), and does not synchronize its operations, making it suitable for unsynchronized key-value storage. In contrast, ConcurrentHashMap, TreeMap, and Hashtable all prohibit null keys for various reasons, such as thread-safety guarantees or sorting requirements.
A method returns a List<Integer>. The caller wants to ensure the list cannot be modified. Which is the best approach?
Explanation: Option D is correct because `Collections.unmodifiableList()` returns a read-only view of the specified list. Any attempt to modify the returned list (e.g., via `add`, `remove`, `set`) will throw an `UnsupportedOperationException`. This is the standard, recommended approach in the Java Collections Framework to provide an unmodifiable wrapper without copying the underlying data.
Given: TreeSet<Integer> ts = new TreeSet<>(Comparator.reverseOrder()); ts.add(10); ts.add(5); ts.add(20); ts.add(15); System.out.println(ts.first()); What is the result?
Explanation: Option C is correct because `TreeSet` with `Comparator.reverseOrder()` sorts elements in descending order (20, 15, 10, 5). The `first()` method returns the smallest element according to the comparator, which in descending order is the last element in the natural order, i.e., 5.
+15 more Working with Arrays and Collections questions available
Practice all Working with Arrays and Collections questions1. Baseline your knowledge
Start with 10 questions to gauge your current understanding of Working with Arrays and Collections. This tells you whether you need a concept refresher or just practice.
2. Review every explanation
For each question — right or wrong — read the full explanation. Understanding why an answer is correct is more valuable than knowing the answer itself.
3. Focus on exam traps
Working with Arrays and Collections questions on the 1Z0-829 frequently use trap wording. Look for subtle differences in answers that test your precision, not just general knowledge.
4. Reach 80% consistently
Do repeated sessions until you score 80%+ three times in a row. Then move to mixed-mode practice to test cross-topic recall under realistic conditions.
The exact number varies per candidate. Working with Arrays and Collections is tested as part of the Oracle Certified Professional Java SE 17 Developer 1Z0-829 blueprint. Practicing with targeted Working with Arrays and Collections questions ensures you can handle any format or difficulty that appears.
Yes. Courseiva provides free 1Z0-829 practice questions across all exam topics and domains. The platform includes topic-based practice, mock exams, missed-question review, bookmarked questions, and readiness tracking — no account required.
Difficulty is subjective, but Working with Arrays and Collections is a high-priority exam concept tested in multiple ways — direct recall, scenario analysis, and command-output interpretation. Consistent practice is the best way to build confidence.
Launch a full Working with Arrays and Collections practice session with instant scoring and detailed explanations.
Start Working with Arrays and Collections Practice →