3152 questions in repository. There are more than 200 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Ans. It is a Design Pattern that facilitates loose coupling by sending the dependency information ( object references of dependent object ) while building the state of the object. Objects are designed in a manner where they receive instances of the objects from other pieces of code, instead of constructing them internally and hence provide better flexibility.
Help us improve. Please let us know the company, where you were asked this question :
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.
Help us improve. Please let us know the company, where you were asked this question :
Which of the following collection maintain its elements in Natural Sorted order ?
HashMap
TreeMap
LinkedHashMap
LinkedMap
Which method needs to be implemented if a class is implementing comparable interface ?
comp
compare
compareTo
compareEquals
Very frequently asked. Usually followed by questions related to private constructor and synchronized access. Frequently asked in JPMorgan and TCS (Based on 2 feedback)