Test 23 - Free Java SE 25 certification Mock test - Exam Code 1Z0-831-Oracle certified Java SE 25 Professional
Java 25 is going to expect you to know how streams can be extended and how they can be run in parallel. The free mock test for the Oracle 1Z0-831 exam covers all of that. It's all about stream gatherers, concatenation and decomposition and the behaviour of parallel streams. Those are the three areas that differentiate the new exam from the previous ones.
Gatherers are the star of the show. A Gatherer is a custom intermediate operation that you apply via Stream.gather. It's for the transformations that the standard operations simply can't do. You'll be using the built in factories in java.util.stream.Gatherers (windowFixed, windowSliding, fold, scan and mapConcurrent). The questions are all about what a sliding window of size 3 would produce from a short sequence, what happens when a fixed window encounters a final partial group and how the output of scan differs from the output of a final reduction. You'll also see how gatherers can be composed with andThen and how they sit in between the normal pipeline stages.
Decomposition and concatenation form the next group. Stream.concat joins two streams in sequence, flatMap flattens nested structures and takeWhile, dropWhile, limit and skip all split the stream by position or condition. You'll be looking at the contents of the stream when these are chained together, particularly when dealing with infinite sources where limit is absolutely vital.
Parallel streams present a whole different set of puzzles. Calling parallelStream() or parallel() will enable concurrent processing, but the exam is all about the ramifications. A forEach() will print out in any order, a forEachOrdered() will respect the encounter order. You'll definitely come across the race conditions if you're trying to accumulate into a shared ArrayList from a parallel stream and you'll need to identify those and pick a correct collector. Reduction operations must be associative and a non-associative accumulator (e.g. subtraction) can give you all sorts of strange results.
You'll also see which stateful operations (sorted, distinct etc) are the ones that ultimately limit the benefit of parallelism. You'll see why the source of a stream and its size will affect whether going parallel actually makes any difference at all. The explanations make a clear distinction between what is guaranteed and what is merely something that can happen. Remember that with unordered sources (like a HashSet) the parallel results are even more difficult to predict so very few of the questions are actually order dependent. Learn what is guaranteed and what isn't. Do the test, go through every miss and check the behaviour in a scratch project, running each of the parallel examples a few times to see how the results vary.
