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:
Verified
Q78: A portion of your program includes the
Q79: BBBBBBBBBBBBBBBBBBBBBBBBBBThe code segment below displays a table
Q80: The method findLargest examines the elements of
Q81: Complete the code shown to define the
Q82: Which of the following statements correctly provides
Q84: Suppose a developer gets class XYZ files
Q85: Which of the following classes implement the
Q86: The _ class contains a sort method
Q87: Suppose the call obj1.compareTo(obj2) returns 0.What can
Q88: Which of the following statements correctly specifies
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents