Given the code fragment:
BiFunction
System.out.println(val.apply(10, 10.5));
What is the result?
Given the code fragment:
BiFunction
System.out.println(val.apply(10, 10.5));
What is the result?
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.
Compiler error in this line BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; Cannot convert from Integer to Double
C,tested
The Correct Answer: D since do not see the n2 but see the n1 there
C is the correct answer
C is correct since summing Integer and Double gives Double which can't be implicitly cast to Integer.
Answer is C. Bad return type in lambda expression: double cannot be converted to Integer
Answer C cannot convert from double to Integer