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

Given:

What is the result?

    Correct Answer: C

    The code creates an array of cat names and then adds those names to an ArrayList. It sorts the ArrayList in descending order using the lambda expression `(var a, var b) -> -a.compareTo(b)`, where the minus sign reverses the natural order of comparison. Finally, it prints each element of the sorted list. The correct result is the cat names in descending alphabetical order: sphynx, oxicat, laperm, korat, bengal, abyssinian.

Discussion
eldonivanOption: C

The default sort order is ascending. The line -a.compareTo(b) changes the order to descending. The answer is: C

StavokOption: C

C is correct TESTED

OmnisumemOption: C

Tested: C.

tmuralimanoharOption: C

Answer:C

ASPushkinOption: C

interesting thing : var cats = new ArrayList<>(Arrays.asList(catNames)); Diamond Operator - compiler's type inference feature determines the most suitable constructor declaration that matches the invocation. This is not a row type.

mendjijetOption: C

C is corrrect the sort is inversed -a.compareTo(b)

SampsOption: C

C is correct