Question: Fill in the blank with the functional interface from java.util.function that allows the code to compile and print 3 at runtime. _____________ transformer = x
Fill in the blank with the functional interface from java.util.function that allows the code to compile and print 3 at runtime. _____________ transformer = x -> x;

A. Function
B. UnaryOperator
C. ToIntFunction
D. IntUnaryOperator
E. The code does not compile regardless of what functional interface is placed in the blank.
F. The code is capable of compiling, but since prime is an OptionalInt value, it cannot be 3 at runtime.
var prime = List. of (3,1,4,1,5,9) .stream() .limit (1) .peek (s -> {}) .mapToInt (transformer) .peek (s -> {}) .sum(); System.out.println(prime);
Step by Step Solution
3.34 Rating (151 Votes )
There are 3 Steps involved in it
The provided code snippet is using a stream to process a list of integers and then sum their values ... View full answer
Get step-by-step solutions from verified subject matter experts
