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

Given the code fragment:

What is the result?

    Correct Answer: C

    The code uses parallelStream, which means the order of execution for the reduce operation is not guaranteed to be sequential. This could lead to the string concatenation happening in any order, producing different results. Consequently, the program might print either 'Java EEJava SE' or 'Java SEJava EE'.

Discussion
laura_lu93Option: D

tested is D

Svetleto13Option: D

D,tested

Svetleto13

If we test the code with stream(),not parallelStream(),answer is B.

JME_CHGOption: C

B and D are both possibilities... "Java" is not a true identity so can give unexpected results, but due to encounter order, will always be EE before SE...

steefaandOption: D

Answer is D. Tested.

OhayouOption: D

Answer D

Eason_from_the_futureOption: D

D, tested public static void main(String[] args) { List<String> nums = Arrays.asList("EE", "SE"); String ans = nums.parallelStream().reduce("Java", (a, b) -> a.concat(b)); System.out.println(ans); }

Abdullah_RahahleahOption: C

Because it's parallelStream,