Question
Which statement about Comparable vs Comparator is the strongest interview answer?
- Comparable defines a natural order for a type, while Comparator provides external or alternative ordering logic.
- Comparable vs Comparator is mostly a naming style choice and has little effect on runtime or design.
- Comparable vs Comparator exists mainly to reduce the number of Java files in a project.
- Comparable vs Comparator matters only for frontend frameworks, not for core Java applications.
Hint
Start with the core rule behind Comparable vs Comparator.
Answer and rationale
Correct answer: A. Comparable defines a natural order for a type, while Comparator provides external or alternative ordering logic.
Comparable defines a natural order for a type, while Comparator provides external or alternative ordering logic. This is the base concept interviewers commonly test first.
Track: Java