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

Given the code fragment:

What is the result?

    Correct Answer: C

    The given code segment involves creating two lists: list1, which is modifiable, and list2, which is created using List.copyOf(list1). The List.copyOf() method returns an unmodifiable (immutable) copy of the given list. When the code attempts to sort list2, it will throw a java.lang.UnsupportedOperationException since an immutable list cannot be modified. Therefore, the result is a java.lang.UnsupportedOperationException being thrown.

Discussion
RP384Option: C

List.copyOf() returns un-modifiable list.

d7bb0b2Option: C

C , because an immutable list cannot be sorted or modified

OmnisumemOption: C

Tested: C.

tmuralimanoharOption: C

Answer: C

StavokOption: C

C is correct

Mukes877Option: C

List.copyOf() returns immutable list.

TADIEWAOption: C

c correct