Java SE 8 Programmer II — Question 30
java.util.function.Function interface?
Which statement is true about the single abstract method of the void.
Answer options
- A. It accepts one argument and returns boolean.
- B. It accepts one argument and returns
- 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: C
Explanation
The correct answer is C because the java.util.function.Function interface's abstract method is designed to take one argument and produce a result of the same type as that argument. Option A is incorrect because it states that the method returns a boolean, which is not true. Option B is incomplete, and option D is incorrect as it suggests the method can return any data type, which goes against the type consistency of the Function interface.