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

Given the code fragment:

List doubles = Arrays.asList (100.12, 200.32);

DoubleFunction funD = d ""> d + 100.0;

doubles.stream (). forEach (funD); // line n1 doubles.stream(). forEach(e ""> System.out.println(e)); // line n2

What is the result?

    Correct Answer: D

    A

Discussion
mevltOption: D

Answer is D. forEach is a void method however DoubleFunction return double values

jduarteOption: D

Answer is D

Abdullah_RahahleahOption: A

forEach takes consumer not function

pul26Option: D

Sorry I meant Answer is D

steefaandOption: D

D is answer. Tested, forEach accepts Consumer or BiConsumer.

WilsonKKerllOption: A

line n1 ->> doubles.stream().map(x -> funD.apply(x)).forEach(System.out::println);

Svetleto13Option: D

D,tested.Required type Consumer,provided DoubleFunction on line 1-forEach (funD);

pul26Option: A

Answer is A public static void main(String[] args) { List<Double> doubles = Arrays.asList (100.12, 200.32); DoubleFunction funD = d -> d + 100.0; // compile error doubles.stream ().jmsforEach(funD); // line n1 doubles.stream(). forEach(e -> System.out.println(e)); // line n2 }