Oracle
1Z0-819 · Question #86
Given: List<String> list1 = new ArrayList<>(); list1.add("A"); list1.add("B"); list1.add("C"); List<String> list2 = List.of(list1, list2); List<String> list3 = list.of(list1)…
The correct answer is B. An exception is thrown at run time. See the full explanation below for the reasoning.
Question
Given:
List<String> list1 = new ArrayList<>();
list1.add("A");
list1.add("B");
list1.add("C");
List<String> list2 = List.of(list1, list2);
List<String> list3 = list.of(list1);
System.out.println(list3);
What is the result?
Options
- A[A, B, A, B]
- BAn exception is thrown at run time.
- C[A, B, [A, B, C]]
- D[A, B, C], [A, B, C]]
How the community answered
(47 responses)- A9% (4)
- B77% (36)
- C13% (6)
- D2% (1)
Community Discussion
No community discussion yet for this question.