1z0-829 Exam QuestionsBrowse all questions from this exam

1z0-829 Exam - Question 48


Given the code fragment:

Which action sorts the book list?

Show Answer
Correct Answer: B

The method List.of() returns an immutable list, which means the list cannot be modified after it is created. The sort() method of the List interface requires the list to be mutable because it tries to modify the list in place. Therefore, converting the books type to a mutable ArrayList type at Line n1 will allow the sort() method to work, properly sorting the list based on the titles of the books.

Discussion

1 comment
Sign in to comment
xplorerpjOption: B
Jun 25, 2024

B is correct answer. List is immutable