1Z0-829 Working with Arrays and Collections Practice Question
A developer needs to filter a list of transactions where the amount is greater than 100 and collect the results into a new list. Which approach is best practice for readability and performance?
⚠ Common exam trap
Candidates often choose Option D, thinking `removeIf` is a filter, but it mutates the original collection and does not create a new list, which is explicitly required by the question.
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
✓
transactions.stream().filter(t -> t.getAmount() > 100).collect(Collectors.toList())
It uses the Stream API's `filter` method to declaratively select transactions with an amount greater than 100, and `collect(Collectors.toList())` to gather results into a new list. This approach is both readable and performant, leveraging lazy evaluation and internal iteration for efficient processing.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
transactions.stream().filter(t -> t.getAmount() > 100).collect(Collectors.toList())
Why this is correct
Stream API is best practice for filtering and collecting into a new list.
- ✗
List<Transaction> result = new ArrayList<>(); for(Transaction t : transactions) { if(t.getAmount() > 100) result.add(t); }
Why it's wrong here
Using a for loop is more verbose and less declarative than streams.
- ✗
transactions.stream().filter(t -> t.getAmount() > 100).toArray()
Why it's wrong here
Collecting to an array is less flexible than a list for further operations.
- ✗
transactions.removeIf(t -> t.getAmount() <= 100)
Why it's wrong here
This modifies the original list, which may not be intended.
Go deeper
Related to this question
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 →
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.