exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 162 discussion

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

Given the code fragment:
List<Double> 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?

  • A. A compilation error occurs at line n2.
  • B. 200.12 300.32
  • C. 100.12 200.32
  • D. A compilation error occurs at line n1.
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
6c84cb9
4 months, 3 weeks ago
Answer: D. Due to a type mismatch in the first forEach (on line n1), compilation will fail with an error. So the correct answer is: D. A compilation error occurs at line n1.
upvoted 1 times
...
steefaand
11 months, 4 weeks ago
Selected Answer: D
D is answer. Tested, forEach accepts Consumer or BiConsumer.
upvoted 2 times
...
WilsonKKerll
2 years, 10 months ago
line n1 ->> doubles.stream().map(x -> funD.apply(x)).forEach(System.out::println);
upvoted 1 times
...
mevlt
2 years, 11 months ago
Answer is D. forEach is a void method however DoubleFunction return double values
upvoted 3 times
...
Svetleto13
3 years, 8 months ago
D,tested.Required type Consumer,provided DoubleFunction on line 1-forEach (funD);
upvoted 1 times
...
jduarte
4 years ago
Answer is D
upvoted 3 times
...
Abdullah_Rahahleah
4 years, 1 month ago
forEach takes consumer not function
upvoted 3 times
...
pul26
4 years, 1 month ago
Sorry I meant Answer is D
upvoted 3 times
...
pul26
4 years, 1 month ago
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 }
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