int x = 0, y = 0, z = 10; while (x < z) { y = y + x; if (y > 10) { y = y / 2; } x++; }
for
statement.hour
and minute
fields,
a constructor to initialize a time, and a tick() method to advance the time
by one minute.
Clock clock1 = new Clock(2, 43); Clock clock2 = clock1; clock1.tick();How many clocks have been constructed in the above code? What time is stored in clock2 after the code executes?
/** * Compares this object with the Clock on the right-hand side. * * @param rhs (right-hand-side) The object with which to compare this Clock. * @return -1 if this Time comes before rhs (if both are in the same day),
* 1 if this Clock comes after rhs, * and 0 is they are equal. */ public int compareTo(Object rhs) {