Solved

What Must Be True About the Return Value from the Implementation

Question 14

Multiple Choice

What must be true about the return value from the implementation of the compare method for the Comparator interface when comparing two objects, a and b with a call to compare(a, 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 a negative value if a comes before b, 0 if they are the same, and a positive value 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 -1 if a comes before b, 0 if they are the same, and 1 if a comes after b.

Correct Answer:

verifed

Verified

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

Related Questions