← Quiz: Comparable vs Comparator: all 10 questions
Quiz: Comparable vs Comparator · Question 6 of 10
comparing(Student::name).thenComparing(Student::marks).reversed() sorts by:
comparing(Student::name).thenComparing(Student::marks).reversed() sorts by:
- A.name ascending, then marks descending
- B.name descending, then marks ascending
- C.name descending, then marks descending
- D.marks descending only
Answer & explanation
Correct answer: name descending, then marks descending
reversed() flips the whole comparator built so far, so both keys are reversed.
Can you get the rest right without peeking?
Take the timed Quiz: Comparable vs Comparator quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →