Which statement is true about the single abstract method of the java.util.function.Function interface?
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.
D function C is unaryoperator
C should be Correct
Function
Function f = new Function() {
public Double apply(Integer t) {
return t;
}
};
the result will always be that of type R
Function
D
Function
D
C is correct.
When creating a Function you need to pass two types, first the T, and then R for the return class.
public interface Function and R apply(T t);
Function will become a Integer apply(String t)
formating issues, please consider generics types after “Function” String,Integer
Nevermind, just read again and “a result of the same type as the argument” is incorrect. Awnser is D then.
d:
It looks like the answer for this question should be D.
Public interface Function; R apply(T t). The function method accepts type t argument and return a generic type R, which could be any data type.