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

Given the code fragment:

List list1 = Arrays.asList(10, 20);

List list2 = Arrays.asList(15, 30);

//line n1

Which code fragment, when inserted at line n1, prints 10 20 15 30?

    Correct Answer: A

    Stream.of(list1, list2) creates a Stream of the two lists. flatMap(list -> list.stream()) flattens this Stream of lists into a single Stream containing the elements of both lists. forEach(s -> System.out.print(s +

Discussion
thetechOption: A

Sorry Answer is A. Tested

M_JawadOption: A

the answer is A

ayzoOption: A

A tested

jduarteOption: A

Answer is A. Tested

asdfjhfgjuaDCVOption: A

A is the correct answer

steefaandOption: A

Answer is A

GaelBernardOption: A

Not tested, but I think : - B doesn't compile because List.intStream() doesn't exist - C doesn't compile because Stream.flatMap() expects a function as parameter, while a Stream is provided - D almost compiles but doesn't : flatMapToInt() exists, though a wrong parameter is provided. Expected: Function<List<Integer>, IntStream> Provided: Function<List<Integer>, Stream<Integer>>

WilsonKKerllOption: A

Answer is A.

thetechOption: B

Answer is B. Tested.