EECS1030M Test 1

Wednesday January 21, 2015, 13:00-13:30
Lab 02
Version B


/**
 * This utility class converts kilos to pounds.
 * 
 * @author Franck van Breugel
 */
public class KiloToPound 
{
    private KiloToPound() {}
    
    /**
     * Number of kilos per pound.
     */
    public static final double KILO_PER_POUND =  0.45359237; 
    
    /**
     * Converts the given number of kilos to the corresponding number of pounds.
     * 
     * @param kilos the number of kilos.
     * @pre. kilos >= 0 && kilos <= 1000.0
     * @return the number of pounds corresponding to the given number of kilos.
     */
    public static double convert(double kilos)
    {
	return kilos / KiloToPound.KILO_PER_POUND;
    }
}


Multiple choice question

Question 1 Consider the following method header.
public static void method() throws Exception

Which of the following statements is correct?

A. The compiler gives an error message since the Exception class has not been imported.
B. The Java virtual machine crashes when it tries to invoke the method.
C. The method does not return anything.
D. None of the above.