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

Given the code fragment:

UnaryOperator uo1 = s -> s*2; //line n1

List loanValues = Arrays.asList(1000.0, 2000.0);

loanValues.stream()

.filter(lv -> lv >= 1500)

.map(lv -> uo1.apply(lv)) //line n2

.forEach(s -> System.out.print(s + " "));

What is the result?

    Correct Answer: A

    The code snippet iterates over a list of loan values, filtering out values less than 1500 and then applying a unary operator that doubles each remaining value. The loan value of 2000.0 remains after filtering, and doubling it results in 4000.0. This value is printed out, resulting in the output '4000.0'. Therefore, 4000.0 is the correct result.

Discussion
Abdullah_RahahleahOption: A

A is the correct answer-tested

Svetleto13Option: A

A,tested

asdfjhfgjuaDCVOption: D

D is the correct answer tested. if at line 2 map(lv -> uo1.apply(lv.intValue())) then 4000

asdfjhfgjuaDCV

Sorry A 4000.0 is the correct answer

steefaandOption: A

A is correct.

duydnOption: A

A is correct, tested 22/09/2023