Search Interview Questions | ![]() ![]() Click here and help us by providing the answer. ![]() Click Correct / Improve and please let us know. |
|
| ||||
Core Java - Interview Questions and Answers for 'Comparator' - 2 question(s) found - Order By Newest | ||||
| ||||
Ans. The purpose of comparator interface is to compare objects of the same class to identify the sorting order. Sorted Collection Classes ( TreeSet, TreeMap ) have been designed such to look for this method to identify the sorting order, that is why class need to implement Comparator interface to qualify its objects to be part of Sorted Collections. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
| ||||
Ans. Comparable interface is used for single sequence sorting i.e.sorting the objects based on single data member where as comparator interface is used to sort the object based on multiple data members. | ||||
![]() | ||||
![]() ![]() ![]() ![]() ![]() ![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||
![]() | ||||