Core Java API Flashcards
7 cards from real 1Z0-811 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 Java API flashcards as text
Which method in `Iterable` is used to perform an action for each element?
Answer: forEach()
`Iterable.forEach(Consumer)` iterates over all elements and applies the given action to each.
What is the result of `new StringBuilder("abc").insert(1, "XY")`?
Answer: "aXYbc"
`insert(1, "XY")` inserts "XY" starting at index 1, shifting existing characters right, resulting in "aXYbc".
Which of these correctly declares a `Set` that preserves insertion order?
Answer: new LinkedHashSet<>()
`LinkedHashSet` maintains insertion order using a doubly-linked list alongside the hash table.
What does `LocalDate.now().plusMonths(1).getMonth()` return if today is January 31?
Answer: February
Adding one month to January 31 yields February 28 (or 29 in a leap year); the month is February.
What is the output of `System.out.println(" hello ".strip())`?
Answer: "hello"
`String.strip()` removes leading and trailing whitespace (including Unicode whitespace), returning "hello".
Which collection class is thread-safe and allows concurrent reads and writes?
Answer: ConcurrentHashMap
`ConcurrentHashMap` uses segmented locking to allow concurrent reads and a limited number of concurrent writes safely.
What is the return type of `Map.entrySet()`?
Answer: Set>
`Map.entrySet()` returns a `Set>` containing all key-value pair entries in the map.