Oracle
1Z0-819 · Question #105
Given: public static void main(String[] args) { final List<String> fruits = List.of("Orange", "Apple", "Lemon", "Raspberry"); final List<String> types = List.of("Juice", "Pie", "Ice", "Tart"); final…
The correct answer is B. Orange Juice Apple Pie Lemon Ice Raspberry Tart. See the full explanation below for the reasoning.
Question
Given:
public static void main(String[] args) {
final List<String> fruits =
List.of("Orange", "Apple", "Lemon", "Raspberry");
final List<String> types =
List.of("Juice", "Pie", "Ice", "Tart");
final var stream =
IntStream.range(0, Math.min(fruits.size(), types.size()))
.mapToObj(i -> fruits.get(i) + " " + types.get(i) );
stream.forEach(System.out::println);
}
What is the result?
Options
- AOrange Apple Lemon Raspberry
- BOrange Juice Apple Pie Lemon Ice Raspberry Tart
- CThe compilation fails.
How the community answered
(68 responses)- A10% (7)
- B72% (49)
- C18% (12)
Community Discussion
No community discussion yet for this question.