← All 1Z0-819 Flashcard Decks

Functional Interfaces Flashcards

7 cards from real 1Z0-819 practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Functional Interfaces flashcards as text
  1. What is the correct return type of `BiFunction`?

    Answer: Boolean

    The third type parameter of BiFunction is the return type R, so Boolean is returned.

  2. Given `Function f = String::length;` and `Function g = i -> "len:"+i;`, what does `f.andThen(g).apply("hi")` return?

    Answer: "len:2"

    andThen applies f first (length=2) then g, producing "len:2".

  3. What is the difference between `Function.andThen(g)` and `Function.compose(g)`?

    Answer: andThen applies g after this function; compose applies g before

    andThen(g) means this → g; compose(g) means g → this, reversing the application order.

  4. Which method on `Predicate` returns a new Predicate that is the logical negation of the original?

    Answer: negate()

    Predicate.negate() returns a new Predicate that represents the logical NOT of the original predicate.

  5. What does `Predicate.and(Predicate other)` short-circuit on?

    Answer: It short-circuits when the first predicate is false

    Predicate.and() short-circuits on false — if the first predicate returns false, the second is never evaluated.

  6. Which functional interface represents an operation that accepts two input arguments and returns no result?

    Answer: BiConsumer

    BiConsumer accepts two arguments and returns void, making it the two-argument form of Consumer.

  7. What happens when you call `consumer1.andThen(consumer2).accept(x)`?

    Answer: consumer1 is called first, then consumer2

    Consumer.andThen() returns a composed Consumer that executes this consumer first, then the argument consumer.