Given the code fragment: BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; //line n1 System.out.println(val.apply(10, 10.5)); What is the result?
Click on the arrows to vote for the correct answer
A. B. C. D.C.
The code fragment defines a BiFunction object named val which takes in two arguments, an Integer and a Double, and returns an Integer. The lambda expression assigned to val sums the two arguments and returns their integer sum.
sqlBiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; When val.apply(10, 10.5) is called, the apply method of the BiFunction object val is invoked with the arguments 10 and 10.5. Since 10.5 is a Double value and not an Integer, it will be automatically unboxed to a double primitive value. The apply method then adds 10 and 10.5 (which is equal to 20.5) and returns the result as an Integer.
kotlinSystem.out.println(val.apply(10, 10.5)); // Output: 20 Therefore, the correct answer is (A) 20.