Java OCA OCP Practice Question 1651

Question

Which functional interface returns a primitive value?

A.   BiPredicate
B.   CharSupplier
C.   LongFunction
D.   UnaryOperator


A.

Note

Option A is the correct answer because BiPredicate takes two generic types and returns a primitive boolean value.

Option B is incorrect, since CharSupplier does not exist in java.util.function.

Option C is also incorrect, since LongFunction takes a primitive long value and returns a generic type.

Remember, Java only includes primitive functional interfaces that operate on double, int, or long.

Finally, Option D is incorrect.

UnaryOperator takes a generic type and returns a generic value.




PreviousNext

Related