Олимпиадный тренинг

Задача . 37353


Задача

Темы:
public class Temperature
{
private String scale; //valid values are "F" or "C"
private double degrees;
/** constructor with specified degrees and scale */
public Temperature(double tempDegrees, String tempScale)
{ /* implementation not shown */ }
/** Mutator. Converts this Temperature to degrees Fahrenheit.
* Precondition: Temperature is a valid temperature
* in degrees Celsius.
* @return this temperature in degrees Fahrenheit
*/
public Temperature toFahrenheit()
{ /* implementation not shown */ }
/** Mutator. Converts this Temperature to degrees Celsius.
* Precondition: Temperature is a valid temperature
* in degrees Fahrenheit.
* @return this temperature in degrees Celsius
*/
public Temperature toCelsius()
{ /* implementation not shown */ }
/** Mutator.
* @param amt the number of degrees to raise this temperature
* @return this temperature raised by amt degrees
*/
public Temperature raise(double amt)
{ /* implementation not shown */ }
/** Mutator.
* @param amt the number of degrees to lower this temperature
* @return this temperature lowered by amt degrees
*/
public Temperature lower(double amt)
{ /* implementation not shown */ }
/** @param tempDegrees the number of degrees
* @param tempScale the temperature scale
* @return true if tempDegrees is a valid temperature
* in the given temperature scale, false otherwise
*/
public static boolean isValidTemp(double tempDegrees,
String tempScale)
{ /* implementation not shown */ }
//Other methods are not shown.
}


A client method contains this code segment:
Temperature t1 = new Temperature(40, "C");
Temperature t2 = t1;
Temperature t3 = t2.lower(20);
Temperature t4 = t1.toFahrenheit();

Which statement is true following execution of this segment?

(A) t1, t2, t3, and t4 all represent the identical temperature, in degrees Celsius.
(B) t1, t2, t3, and t4 all represent the identical temperature, in degrees Fahrenheit.
(C) t4 represents a Fahrenheit temperature, while t1, t2, and t3 all represent degrees Celsius.
(D) t1 and t2 refer to the same Temperature object; t3 refers to a Temperature object that is 20 degrees lower than t1 and t2, while t4 refers to an object
that is t1 converted to Fahrenheit.
(E) A NullReferenceException was thrown.

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя