1Z0-811 Arrays and Methods Practice Question
A developer wants to sort an array of primitive ints in descending order. Which approach will work without using third-party libraries?
⚠ Common exam trap
Watch out — candidates often assume `Arrays.sort()` with a comparator works on primitive arrays, but Java's type system prevents this because comparators require object types, leading to a compilation error for `int[]`.
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
✓
Arrays.sort(arr); // then reverse the array manually
`Arrays.sort(int[])` sorts the array in ascending order, and then manually reversing the array yields descending order. The other options fail because `Arrays.parallelSort()` also sorts ascending, `Collections.reverseOrder()` requires an array of objects (not primitives), and a custom comparator cannot be used with primitive arrays in Java.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Arrays.parallelSort(arr);
Why it's wrong here
Sorts in ascending order, not descending.
- ✗
Arrays.sort(arr, Collections.reverseOrder());
Why it's wrong here
reverseOrder() requires an Object array, not primitive int[].
- ✓
Arrays.sort(arr); // then reverse the array manually
Why this is correct
Sorts ascending, then reversing yields descending order.
- ✗
Arrays.sort(arr, (a,b) -> b - a);
Why it's wrong here
Lambda comparator requires an Object array; cannot be used with int[].
Go deeper
Related to this question
About these practice questions
One of 481 original 1Z0-811 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-811 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-811 exam.