exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 79 discussion

Actual exam question from Oracle's 1z0-809
Question #: 79
Topic #: 1
[All 1z0-809 Questions]

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?

  • A. Stream.of(list1, list2) .flatMap(list -> list.stream()) .forEach(s -> System.out.print(s + " "));
  • B. Stream.of(list1, list2) .flatMap(list -> list.intStream()) .forEach(s -> System.out.print(s + " "));
  • C. list1.stream() .flatMap(list2.stream().flatMap(e1 -> e1.stream()) .forEach(s -> System.out.println(s + " "));
  • D. Stream.of(list1, list2) .flatMapToInt(list -> list.stream()) .forEach(s -> System.out.print(s + " "));
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
thetech
Highly Voted 4 years, 8 months ago
Sorry Answer is A. Tested
upvoted 14 times
...
M_Jawad
Highly Voted 4 years, 6 months ago
the answer is A
upvoted 8 times
...
asdfjhfgjuaDCV
Most Recent 4 months, 3 weeks ago
A is the correct answer
upvoted 1 times
...
steefaand
5 months, 3 weeks ago
Selected Answer: A
Answer is A
upvoted 1 times
...
GaelBernard
11 months, 3 weeks ago
Selected Answer: 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>>
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Answer is A.
upvoted 1 times
...
jduarte
3 years, 4 months ago
Answer is A. Tested
upvoted 2 times
...
ayzo
3 years, 6 months ago
A tested
upvoted 3 times
...
thetech
4 years, 8 months ago
Answer is B. Tested.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago