Consider the following code segments that are potential replacements for /* missing code */.
I. Double d1 = new Double(temperature);
Double d2 = new Double(other.temperature);
return d1.compareTo(d2);
II. if (temperature < other.temperature)
return -1;
else if (temperature == other.temperature)
return 0;
else return 1;
III. return (int) (temperature - other.temperature);
Which of the code segments could be used to replace /* missing code */ so that compareTo can be used to order TemperatureReading objects by increasing temperature value?
A) II only.
B) I and II only.
C) I and III only.
D) II and III only.
E) I, II, and III.

Respuesta :

Answer:

C. I and III only.

Explanation:

The segment code is text portion of the document of file. It contains executable instructions for the system. The temperature value increase is replaced by instructions which create the same output.

ACCESS MORE