Courseiva
Working with Arrays and CollectionseasyMultiple SelectObjective-mapped

1Z0-829 Working with Arrays and Collections Practice Question

Which TWO of the following will sort a List<String> in natural (ascending) order?

⚠ Common exam trap

Many candidates confuse `Collections.sort(list)` (which sorts in natural order) with `Collections.sort(list, Collections.reverseOrder())` (which sorts in reverse order), and may also mistakenly think `Arrays.sort()` works on a `List` without realizing it requires an array.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

list.sort(Comparator.naturalOrder());

`Comparator.naturalOrder()` returns a comparator that imposes the natural (ascending) ordering on `String` objects, which is lexicographic order based on Unicode values. The `List.sort()` method accepts this comparator and sorts the list in place, making it a concise and idiomatic way to sort a list in ascending order.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • list.sort(Comparator.naturalOrder());

    Why this is correct

    Correct: naturalOrder comparator sorts in ascending order.

  • list.sort((a,b) -> b.compareTo(a));

    Why it's wrong here

    Incorrect: comparing b to a reverses the order, resulting in descending.

  • Collections.sort(list, Collections.reverseOrder());

    Why it's wrong here

    Incorrect: reverseOrder sorts in descending order.

  • Collections.sort(list);

    Why this is correct

    Correct: Collections.sort sorts the list in natural order.

  • Arrays.sort(list);

    Why it's wrong here

    Incorrect: Arrays.sort does not accept a List; it works on arrays only.

About these practice questions

This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.