1Z0-829 Working with Streams and Lambda Expressions Practice Question
Exhibit
Refer to the exhibit.
```java
List<Integer> numbers = Arrays.asList(2, 3, 4, 5);
int result = numbers.stream()
.filter(n -> n % 2 == 0)
.mapToInt(n -> n * 3)
.sum();
System.out.println(result);
```What is the output of the code above?
⚠ Common exam trap
Oracle often tests the interaction between `flatMap`, `filter`, and `limit` or `skip`, where candidates forget that `limit` truncates the stream after the filter, leading to an incorrect sum based on the first few elements rather than all matching elements.
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
✓
18
The code creates a stream of lists containing numbers 1 through 9, flatMaps to a single stream of integers, filters for numbers divisible by 3 (leaving 3, 6, 9), and reduces them by summing. The sum is 3+6+9=18, making option A correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
18
Why this is correct
Correct: (2*3)+(4*3)=6+12=18.
- ✗
15
Why it's wrong here
Incorrect: Might have forgotten filter.
- ✗
9
Why it's wrong here
Incorrect: That would be sum of 2+3+4? No.
- ✗
27
Why it's wrong here
Incorrect: If all numbers were processed: (2+3+4+5)*3=42? No.
Go deeper
Related to this question
About these practice questions
One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.