Test: Adv App (Java) Mid Term Exam- Advanced... Google Chrome ure https://udc.bl
ID: 3724856 • Letter: T
Question
Test: Adv App (Java) Mid Term Exam- Advanced... Google Chrome ure https://udc.blackboard.com/webapps/assessment/take/launchjsp?course assessment QUESTION 12 In your own words, in terms of ordering compare() method. Describe the contract using Object o1, Object 02 being passed as method. You should include inyour discussion the Comparator is potentially used. objects, descmbe the general contract of java ubl Comparator parameters to type of class java.util Comparator is, and where a E T T ::Paragraph , Arial : 12pt) THL CSS words:0 Path: p QUESTION 13 Using the Si interface from the handout and the following method oid fm(Si s) Save and Submit to save and submit. Click Save All Answers to save all answers Save All AnswersExplanation / Answer
In Java, Comparator is defined as an interface. The comparator can be used with various of the inbuilt function of sorting, etc to get an extra control over them. Eg. You want Arrays.sort to sort the number in reverse order. In such a case we will have to make use of the interface Comparator to tweak with the original logic of comparison behind the function SORT.
The interface provides us with two of the utility function:-
int comp(Object1, Object2)
This function is used to define the parameter or conditions based on which we can conclude that which Object is greater. Eg:- If the 2 objects were strings namely a & b, then
could have been used to determine which of the string object is greater than the other.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.