🎙 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 3 of 10

Which interface would you implement INSIDE a class to give it a natural order?

Which interface would you implement INSIDE a class to give it a natural order?

  1. A.Comparator
  2. B.Comparable
  3. C.Iterable
  4. D.Cloneable
Answer & explanation

Correct answer: Comparable

Comparable.compareTo defines the class's own natural order.

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 →