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
What does `Arrays.copyOfRange(arr, 1, 4)` return for `arr = {10,20,30,40,50}`?
Answer: {20,30,40}
`copyOfRange(arr, 1, 4)` copies elements at indices 1, 2, and 3 (exclusive end), yielding {20,30,40}.
Which `String` method checks whether the string begins with a given prefix?
Answer: startsWith()
`String.startsWith(prefix)` returns true if the string starts with the specified prefix.
What is printed by `System.out.println(Double.isNaN(0.0 / 0.0))`?
Answer: true
Dividing 0.0 by 0.0 with floating-point arithmetic produces NaN, so `Double.isNaN()` returns true.
Which method on `Queue` retrieves and removes the head, or returns null if empty?
Answer: poll()
`Queue.poll()` retrieves and removes the head element, returning null if the queue is empty.
What is the effect of calling `Collections.sort(list, Comparator.reverseOrder())`?
Answer: Sorts list in descending order
`Comparator.reverseOrder()` produces a comparator that imposes the reverse of the natural ordering, sorting the list in descending order.
What does `String.join("-", "a", "b", "c")` return?
Answer: "a-b-c"
`String.join(delimiter, elements...)` concatenates the elements with the delimiter between each pair, producing "a-b-c".
Which method converts a `Stream` to an `Optional` containing the first element?
Answer: findFirst()
`Stream.findFirst()` returns an `Optional` describing the first element of the stream, or an empty Optional if the stream is empty.