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
What does `String.valueOf(null)` return?
Answer: "null"
`String.valueOf((Object) null)` returns the string literal `"null"` rather than throwing an exception.
Which `List` factory method (Java 9+) produces an immutable list?
Answer: List.of()
`List.of()` introduced in Java 9 returns a truly immutable list; `Arrays.asList` is only structurally fixed but not immutable.
What is printed by: `var sb = new StringBuilder("abc"); sb.reverse(); System.out.println(sb);`?
Answer: cba
`StringBuilder.reverse()` reverses the character sequence in-place and returns the same `StringBuilder`, so printing it shows "cba".
Which `Map` method atomically replaces the value for a key using a remapping function if the key exists?
Answer: computeIfPresent()
`computeIfPresent(key, biFunction)` calls the function with the key and current value only when the key is already mapped to a non-null value.
What does `Stream.of("a","b","c").skip(1).limit(1).findFirst()` return?
Answer: Optional[b]
`skip(1)` discards "a", leaving "b" and "c"; `limit(1)` keeps only "b"; `findFirst()` returns `Optional[b]`.
Which `Comparator` method reverses an existing comparator?
Answer: reversed()
`Comparator.reversed()` returns a comparator that imposes the reverse ordering of the original.
What is the result of `Integer.parseInt("0xFF", 16)`?
Answer: Throws NumberFormatException
`parseInt` with radix 16 does not accept the `0x` prefix — only the hex digits themselves — so it throws `NumberFormatException`.