Oracle
1Z0-851 · Question #168
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true? (Choose two.)
The correct answer is A. The class implements java.lang.Comparable. C. The interface used to implement sorting allows this class to define only one sort sequence. See the full explanation below for the reasoning.
Question
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true? (Choose two.)
Options
- AThe class implements java.lang.Comparable.
- BThe class implements java.util.Comparator.
- CThe interface used to implement sorting allows this class to define only one sort sequence.
- DThe interface used to implement sorting allows this class to define many different sort sequences.
How the community answered
(47 responses)- A77% (36)
- B17% (8)
- D6% (3)
Community Discussion
No community discussion yet for this question.