Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 198

Given the code fragment:

What is the result?

    Correct Answer: C

    The code snippet uses `parallelStream()` to print the elements in a potentially non-deterministic order. The first call to `parallelStream().forEach(s -> System.out.print(s));` can output the elements in any order since parallel streams do not guarantee any specific order. The second call to `parallelStream().forEachOrdered(s1 -> System.out.print(s1));` ensures that the elements are printed in their encounter order (the order in which they appear in the list). Given the list order is B, C, A, D, the two sections will output a random order of the elements followed by BCAD in the encounter order. Therefore, the correct answer is BCAD after some random order output.

Discussion
Svetleto13Option: C

The answer is ADCB BCAD.So,it should be C if we change the answer to this.

WilsonKKerllOption: C

Answer is C.

jduarteOption: C

Answer C. tested

DarGrinOption: C

Answer is C. ACDB (in random order) B C A D

steefaandOption: C

C is correct.

duydnOption: C

C is correct