Solved

When Your Class Implements a Comparator Object, You Must Implement

Question 102

Multiple Choice

When your class implements a comparator object, you must implement the compare method. What must be true about the return value from this method when comparing two objects, a and b with a call to a.compare(b) ?


A) It must return 1 if a comes before b, 0 if they are the same, and -1 if a comes after b.
B) It must return -1 if a comes before b, 0 if they are the same, and 1 if a comes after b.
C) It must return a positive value if a comes before b, 0 if they are the same, and a negative value if a comes after b.
D) It must return a negative value if a comes before b, 0 if they are the same, and a positive value if a comes after b.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents