Java SE 11 Developer (1Z0-819) — Question 147
Which three initialization statements are valid? (Choose three.)
Answer options
- A. var loc = Arrays.of(“UK”, “US”, “ES”);
- B. var loc = List.of(“UK”, “US”);
- C. var loc = List.of(“UK”, null, “US”);
- D. var loc = Map.of(“UK”, 1, “US”, 2);
- E. var loc = ArrayList.of(“UK”, “US”);
- F. var loc = Set.of(“UK”, “US”, “UK”);
- G. var loc = Set.of(“UK”, “US”);
Correct answer: B, D, G
Explanation
The correct answers, B, D, and G, are valid initialization statements for Java collections. Option A is incorrect because Arrays.of does not exist; E is wrong since ArrayList cannot be initialized this way; F is invalid as it duplicates an element in a Set, which does not allow duplicates.