← All 1Z0-819 Flashcard Decks

Core APIs & Data Manipulation 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 Core APIs & Data Manipulation flashcards as text
  1. Which method on `Optional` executes an action if a value is present and does nothing otherwise?

    Answer: ifPresent()

    `ifPresent(Consumer)` calls the consumer with the value when present and is a no-op when the Optional is empty.

  2. What does `TreeSet` use to order its elements by default?

    Answer: Natural ordering via Comparable

    `TreeSet` relies on the elements' natural ordering (their `Comparable` implementation) unless a custom `Comparator` is provided at construction.

  3. Which statement about `StringJoiner` is true?

    Answer: It can be constructed with a delimiter, optional prefix, and optional suffix

    `StringJoiner(delimiter, prefix, suffix)` builds a joined string with optional surrounding tokens, and returns the empty-value string (not an exception) when no elements are added.

  4. What is the output of: `List list = new ArrayList<>(); list.add(1); list.add(2); list.remove(1);` — what remains?

    Answer: [1]

    `list.remove(1)` uses the index overload (not the object overload) because the argument is an `int`, removing the element at index 1 (value 2), leaving [1].

  5. Which `Stream` collector groups elements into a `Map>` based on a predicate?

    Answer: Collectors.partitioningBy()

    `Collectors.partitioningBy(Predicate)` always produces a two-partition map with `true` and `false` keys.

  6. What is the result of `Duration.between(LocalTime.of(10,0), LocalTime.of(9,0)).toHours()`?

    Answer: -1

    `Duration.between` subtracts the start from the end; since end (9:00) is before start (10:00), the result is a negative duration of -1 hour.

  7. Which method converts an `IntStream` to a `Stream` (boxed)?

    Answer: boxed()

    `IntStream.boxed()` is the idiomatic way to convert a primitive `IntStream` to a `Stream`.