LearnFrenzy
Sign in Take a free test

Arrays in Java · Java Arrays MCQ · Question 20

Which sort does Arrays.sort use for objects? Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 20 Back to Exercise

Which property does Arrays.sort guarantee when sorting an array of objects (e.g. String[])?

  • A It is unstable
  • B It is stable: equal elements keep their relative order Correct
  • C It sorts in descending order
  • D It only works on primitives
Correct Answer: Option B

Objects use TimSort (stable); primitives use dual-pivot quicksort, where stability does not matter.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links