← 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?
- A.Comparator
- B.Comparable
- C.Iterable
- 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 →