← All 1Z0-819 Flashcard Decks

Stream API 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 Stream API flashcards as text
  1. Which terminal operation on a Stream returns an OptionalInt containing the minimum value?

    Answer: IntStream.min()

    IntStream.min() returns an OptionalInt with the minimum value of the stream.

  2. What does the following produce? Stream.of(1,2,3).map(n -> n * 2).filter(n -> n > 3).count()

    Answer: 2

    After doubling: 2,4,6; filtering >3 yields 4,6; count() returns 2.

  3. Which Collector groups elements into a Map where keys are Boolean values?

    Answer: Collectors.partitioningBy()

    Collectors.partitioningBy() splits elements into true/false groups based on a Predicate.

  4. What is the result of IntStream.range(0, 5).sum()?

    Answer: 10

    IntStream.range(0,5) produces 0,1,2,3,4; their sum is 10.

  5. Which method converts a Stream> to a Stream containing only present values in Java 9+?

    Answer: stream.flatMap(Optional::stream)

    Optional.stream() was added in Java 9, making flatMap(Optional::stream) the idiomatic approach.

  6. What does Collectors.joining(", ", "[", "]") produce for Stream.of("a","b","c")?

    Answer: [a, b, c]

    joining with delimiter ", ", prefix "[", and suffix "]" produces [a, b, c].

  7. Which statement about Stream.iterate() in Java 9 is correct?

    Answer: It can accept a Predicate as a stop condition

    Java 9 added a three-argument Stream.iterate(seed, predicate, unaryOperator) that stops when the predicate is false.