Oracle
1Z0-809 · Question #23
Given the code fragment: List<Integer> list1 = Arrays.asList(10, 20); List<Integer> list2 = Arrays.asList(15, 30); //line n1 Which code fragment, when inserted at line n1, prints 10 20 15 30?
The correct answer is A. Stream.of(list1, list2) .flatMap(list -> list.stream()) .forEach(s -> System.out.print(s + " ")). You've hit your session limit · resets 5:20pm (America/New_York)
Question
Given the code fragment:
List<Integer> list1 = Arrays.asList(10, 20);
List<Integer> list2 = Arrays.asList(15, 30);
//line n1
Which code fragment, when inserted at line n1, prints 10 20 15 30?
Options
- AStream.of(list1, list2) .flatMap(list -> list.stream()) .forEach(s -> System.out.print(s + " "));
- BStream.of(list1, list2) .flatMap(list -> list.intStream()) .forEach(s -> System.out.print(s + " "));
- Clist1.stream() .flatMap(list.stream()).flatMap(e1 -> e1.stream()).forEach(s -> System.out.println(s + " "));
- DStream.of(list1, list2) .flatMapToInt(list -> list.stream()) .forEach(s -> System.out.print(s + " "));
How the community answered
(55 responses)- A84% (46)
- B2% (1)
- C11% (6)
- D4% (2)
Explanation
You've hit your session limit · resets 5:20pm (America/New_York)
Community Discussion
No community discussion yet for this question.