Question: Consider the Orderable interface and the partial implementation of the Temperature class defined below: public interface Orderable { { / * * / * *

Consider the Orderable interface and the partial implementation of the
Temperature class defined below:
public interface Orderable
{{
/**/** Returns 1,0,-1,0, or 11 depending on whether the implicit
** object is less than, equal to,, or greater than other.
*/*/
int compareTo ((Object other));
}}
public class Temperature implements Orderable
{{
private String scale;
private double degrees;
////default constructor
public Temperature ()()
{/*{/* implementation not shown */}*/}
////constructor
public Temperature((String tempScale, double tempDegrees))
{/*{/* implementation not shown */}*/}
public int compareTo((Object obj))
{/*{/* implementation not shown */}*/}
public String toString()()
{/*{/* implementation not shown */}*/}
////Other methods are not shown.
}}
Here is a program that finds the lowest of three temperatures:
public class TemperatureMain
{{
/**/** Find smaller of objects a and b.*/.*/
public static Orderable min((Orderable a,, Orderable b))
{{
if ((a..compareTo((b)<0))<0)
return a;
else
return b;
}}
/**/** Find smallest of objects a,, b,, and c.*/.*/
public static Orderable minThree((Orderable a,,
Orderable b,, Orderable c))
{{
return min((min((a,, b),), c));
}}
public static void main((String[][] args))
{{
/*/* code to test minThree method */*/
}}
}}
Which are correct replacements for /*/* code to test minThree method */?*/?
I Temperature t1=1= new Temperature("("C",85)",85);
Temperature t2=2= new Temperature("("F",45)",45);
Temperature t3=3= new Temperature("("F",120)",120);
System.out.println("("The lowest temperature is "+"+
minThree((t1,1, t2,2, t3))3));
II Orderable c1=1= new Temperature("("C",85)",85);
Orderable c2=2= new Temperature("("F",45)",45);
Orderable c3=3= new Temperature("("F",120)",120);
System.out.println("("The lowest temperature is "+"+
minThree((c1,1, c2,2, c3))3));
III Orderable c1=1= new Orderable("("C",85)",85);
Orderable c2=2= new Orderable("("F",45)",45);
Orderable c3=3= new Orderable("("F",120)",120);
System.out.println("("The lowest temperature is "+"+
minThree((c1,1, c2,2, c3))3));
((A)) II only
((B)) I and II only
((C)) II and III only
((D)) I and III only
((E)) I, II,, and III

Step by Step Solution

3.40 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below The correct ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!