1Z0-829 Working with Streams and Lambda Expressions Practice Question
Exhibit
List<Integer> numbers = Arrays.asList(1,2,3,4,5);
long count = numbers.stream().filter(n -> n%2==0).count();
System.out.println("Count: " + count);Refer to the exhibit. What is the output?
⚠ Common exam trap
The trap here is that candidates often forget to account for the filter predicate or misread the list contents, leading them to count all elements or assume a different number of non-'A' elements without carefully tracing the stream operations.
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
✓
Count: 2
The stream filters out all elements equal to "A", leaving only elements that are not "A". Based on the list in the exhibit, there are exactly two such elements (e.g., "B" and "C"), so the count is 2.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Count: 2
Why this is correct
Correct. The filter removes all elements equal to 'A', leaving only non-'A' elements. The exhibit shows exactly two such elements, so the count is 2.
- ✗
Count: 3
Why it's wrong here
Incorrect. A count of 3 would result if there were three non-'A' elements, but the list contains only two.
- ✗
Count: 1
Why it's wrong here
Incorrect. A count of 1 would result if there were only one non-'A' element, but the list contains two.
- ✗
Count: 4
Why it's wrong here
Incorrect. A count of 4 would result if the filter were not applied or if the list had four non-'A' elements. The actual list has fewer.
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.