Java SE 8 Programmer II — Question 146
Which statement is true about the single abstract method of the java.util.function.Function interface?
Answer options
- A. It accepts one argument and returns void.
- B. It accepts one argument and returns boolean.
- C. It accepts one argument and always produces a result of the same type as the argument.
- D. It accepts an argument and produces a result of any data type.
Correct answer: D
Explanation
The correct answer is D because the java.util.function.Function interface allows for one argument and can produce a result of any type, providing flexibility in functional programming. Options A and B are incorrect as they misrepresent the return type, while option C falsely claims that the output must match the input type.