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

Given the code fragment:

What is the result?

    Correct Answer: C

    The code uses List.of to create the list, which results in an immutable list. Attempting to sort this immutable list using clrs.sort(hueSrtr.thenComparing(valueSrtr)) will therefore throw an UnsupportedOperationException at runtime. Consequently, the correct answer is that an exception is thrown at runtime.

Discussion
ASPushkinOption: C

List.of creates unmodifiable list you can’t sort this list in a straightforward manner. clrs.sort() throws runtime exception : java.lang.UnsupportedOperationException in the case of reqular List the answer is A (sorting on the hue field and then on value)

d7bb0b2Option: C

C is correcrt List.of is an inmutable cannot add, sort or modified

d7bb0b2Option: C

C is correct, because List is inmutable, that is not add, remove, update elements or sort List

Felipe47Option: C

C is correct. List.of is a List inmmutable!