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 PracticeOrder the steps to properly implement the Singleton pattern with lazy initialization in Java.
Explanation: The correct order for implementing the Singleton pattern with lazy initialization and double-checked locking is A. The steps must follow a logical sequence: first declare the private static volatile instance variable to ensure visibility across threads, then make the constructor private to prevent external instantiation, then provide the public static getInstance method, and finally implement double-checked locking inside the method. Option B is incorrect because it declares the instance variable after making the constructor private, which is not the standard order; while functionally similar, the proper implementation requires declaring the volatile variable first. Option C places the private constructor after the getInstance method, allowing instantiation before the constructor is private. Option D puts the double-checked locking code before the method is provided, which is syntactically invalid.
A stream pipeline uses groupingBy with a downstream collector to count occurrences. The developer expects a Map<Integer, Long> but gets a compilation error. Which is the correct way to write the collector?
Explanation: Options C and D are both correct ways to produce a Map<Integer, Long> using groupingBy with a downstream collector. Option C uses Collectors.counting(), which is the standard method for counting elements in each group. Option D uses Collectors.summingLong(e -> 1L) to sum a constant 1 for each element, effectively achieving the same count. Options A and B are incorrect: A uses toMap which is not a grouping operation, and B uses Collectors.count() which does not exist (the correct method is counting()).
A 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: Ly 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 `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: 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.
+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 →