Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 132

Which three initialization statements are valid? (Choose three.)

    Correct Answer: B, D, G

    List.of, Map.of, and Set.of are all valid methods for creating unmodifiable collections of their respective types. Arrays.of and ArrayList.of are not valid methods. List.of does not allow null elements, and Set.of does not allow duplicate elements. Therefore, the valid initialization statements here are: List.of(“UK”, “US”); Map.of(“UK”, 1, “US”, 2); and Set.of(“UK”, “US”).

Discussion
OmnisumemOptions: BDG

Tested: BDG.

d7bb0b2Options: BDG

BDG is correct

Ashan_OzlovOptions: BDG

Not tested but a bit obvious

[Removed]Options: BDG

BDG. C throws a NullPointerException and F throws a IllegalArgumentException

StavokOptions: BDG

B. var loc = List.of("UK", "US"); D. var loc = Map.of("UK", 1, "US", 2); G. var loc = Set.of("UK", "US"); List.of, Map.of, and Set.of are all valid methods for creating unmodifiable collections of their respective types. The other options are invalid because: A. Arrays.of is not a valid method. C. List.of does not allow null elements. E. ArrayList.of is not a valid method. F. Set.of does not allow duplicate elements.