nerdexam
Oracle

1Z0-809 · Question #46

Which statement is true about the single abstract method of the java.util.function.Function interface?

The correct answer is D. It accepts an argument and produces a result of any data type. Function<T, R> declares R apply(T t) - two independent type parameters mean the input and output can be completely different types (e.g., Function<String, Integer> parses a String into an Integer). That's why D is correct: no restriction ties the return type to the argument…

Question

Which statement is true about the single abstract method of the java.util.function.Function interface?

Options

  • AIt accepts one argument and returns void.
  • BIt accepts one argument and returns boolean.
  • CIt accepts one argument and always produces a result of the same type as the argument.
  • DIt accepts an argument and produces a result of any data type.

How the community answered

(56 responses)
  • A
    5% (3)
  • B
    13% (7)
  • C
    4% (2)
  • D
    79% (44)

Explanation

Function<T, R> declares R apply(T t) - two independent type parameters mean the input and output can be completely different types (e.g., Function<String, Integer> parses a String into an Integer). That's why D is correct: no restriction ties the return type to the argument type.

Why the distractors fail:

  • A describes Consumer<T> - same single argument, but accept() returns void.
  • B describes Predicate<T> - same single argument, but test() returns boolean.
  • C is the trickiest distractor: Function can return the same type (e.g., Function<String, String>), but it is not required to - the type parameters T and R are independent, so this constraint simply doesn't exist.

Memory tip: Map the four core functional interfaces to their signatures - Supplier gives, Consumer takes, Predicate tests (→ boolean), and Function transforms (T → R, anything to anything).

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice