Given the code fragment:
What is the result:
The answer is D because the code fragment uses the Stream API to create two streams, s1 and s2, and then concatenates them using the concat() method. The resulting stream is then processed in parallel using the parallel() method, and the distinct() method is used to remove duplicate elements. Finally, the forEach() method is used to print the elements of the resulting stream to the console. Since the order of elements in a parallel stream is unpredictable, the output could be any of the options given, but option D is the most likely.Reference:
Oracle Certified Professional: Java SE 17 Developer
OCP Oracle Certified Professional Java SE 17 Developer Study Guide
Currently there are no comments in this discussion, be the first to comment!