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

Given the code fragment:

BiFunction val = (t1, t2) -> t1 + t2; //line n1

System.out.println(val.apply(10, 10.5));

What is the result?

    Correct Answer: C

    The code tries to create a BiFunction that takes an Integer and a Double as input and returns an Integer. However, within the lambda expression, the sum of an Integer and a Double results in a Double. Java does not allow implicit casting from Double to Integer, which leads to a compilation error at line n1.

Discussion
thetechOption: C

Compiler error in this line BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; Cannot convert from Integer to Double

Svetleto13Option: C

C,tested

johnchen88Option: D

The Correct Answer: D since do not see the n2 but see the n1 there

asdfjhfgjuaDCVOption: C

C is the correct answer

steefaandOption: C

C is correct since summing Integer and Double gives Double which can't be implicitly cast to Integer.

WilsonKKerllOption: C

Answer is C. Bad return type in lambda expression: double cannot be converted to Integer

jduarteOption: C

Answer C cannot convert from double to Integer