🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Comparable vs Comparator: all 10 questions

Quiz: Comparable vs Comparator · Question 1 of 10

What does a negative return value from compare(a, b) mean?

What does a negative return value from compare(a, b) mean?

  1. A.a comes before b
  2. B.a comes after b
  3. C.a and b are equal
  4. D.The comparison failed
Answer & explanation

Correct answer: a comes before b

Negative means a sorts first; only the sign is important.

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 →