20+ practice questions focused on Working with Streams and Lambda Expressions — 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 Streams and Lambda Expressions PracticeA company processes financial transactions. Each transaction is represented by a Transaction object with fields: amount (double), currency (String), and type (String). The requirement is to compute the total amount of all transactions of type 'SALE' in USD. The transactions are stored in a List<Transaction>. Which code correctly accomplishes this using streams?
Explanation: Option D correctly filters transactions to only those with type 'SALE' and currency 'USD', then maps each to its amount as a double, and sums them using sum(). This satisfies the requirement exactly: total amount of 'SALE' transactions in USD.
A developer writes the following code using the Stream API: List<String> list = List.of("a", "b", "c"); String result = list.stream().reduce("", (s1, s2) -> s1 + s2); System.out.println(result); What is the output?
Explanation: The correct answer is A because the `reduce` method with an identity value (`""`) and a binary operator (`(s1, s2) -> s1 + s2`) accumulates the stream elements in encounter order. Starting from the identity, it concatenates each element: `"" + "a" = "a"`, then `"a" + "b" = "ab"`, then `"ab" + "c" = "abc"`. The result is a `String`, not an `Optional`, because an identity is provided.
A developer needs to process a stream of integers and collect the results into a Map<Integer, List<Integer>> where keys are the integers themselves and values are lists containing the number and its square. Which collector should be used?
Explanation: Option C is correct because it uses the four-argument overload of `Collectors.toMap()`: a key mapper (`Function.identity()`), a value mapper (a lambda that creates a `List<Integer>` containing the number and its square), a merge function (`(v1, v2) -> v1`) to handle duplicate keys (which won't occur here since keys are unique integers), and a `HashMap::new` supplier to ensure the map type is explicitly `HashMap`. This satisfies the requirement of producing a `Map<Integer, List<Integer>>` where each key maps to a list of the number and its square.
A developer writes: List<Integer> list = List.of(1, 2, 3); Optional<Integer> opt = list.stream().reduce((a, b) -> a + b); System.out.println(opt.get()); What is the result?
Explanation: The `reduce` method with a single argument (a `BinaryOperator`) returns an `Optional` because the stream might be empty. Here, the stream contains three integers, so the reduction computes `1 + 2 = 3`, then `3 + 3 = 6`, yielding `Optional[6]`. Calling `get()` on a non-empty `Optional` returns the contained value `6`, which is printed.
Which statement about the Stream API is true?
Explanation: Option D is correct because a Stream in Java represents a sequence of elements that can be traversed only once. Once a terminal operation (like collect() or forEach()) is invoked on a stream, the stream is consumed and cannot be reused; attempting to do so throws an IllegalStateException. This one-time consumption is a fundamental design principle of the Stream API, ensuring that operations are applied to a single, immutable pipeline.
+15 more Working with Streams and Lambda Expressions questions available
Practice all Working with Streams and Lambda Expressions questions1. Baseline your knowledge
Start with 10 questions to gauge your current understanding of Working with Streams and Lambda Expressions. 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 Streams and Lambda Expressions 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 Streams and Lambda Expressions is tested as part of the Oracle Certified Professional Java SE 17 Developer 1Z0-829 blueprint. Practicing with targeted Working with Streams and Lambda Expressions 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 Streams and Lambda Expressions 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 Streams and Lambda Expressions practice session with instant scoring and detailed explanations.
Start Working with Streams and Lambda Expressions Practice →