Infer outcomes across comparison ties

A developer tests five distinct, non-null Ticket objects named a, b, c, d and e. Their comparison method obeys the full Java Comparable contract, and its outcomes remain unchanged throughout the test. Four observed results are:


Java
a.compareTo(b) == 0
b.compareTo(c) == -4
c.compareTo(d) == 0
d.compareTo(e) == 0


The developer then uses each object as the receiver and calls compareTo once with each of the other four objects. No object is compared with itself. Thus, reversing receiver and argument counts as a separate call.


How many of these calls return a negative integer, how many return zero, and how many return a positive integer? Enter each number of calls as an exact whole number.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Comparable Questions: