EECS1030M Test 1

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


/**
 * This utility class converts newtons to dynes.
 * 
 * @author Franck van Breugel
 */
public class NewtonToDyne 
{
    private NewtonToDyne() {}
    
    /**
     * Number of dynes per newton. 
     */
    public static final int DYNES_PER_NEWTON = 100000;
    
    /**
     * Converts the given number of newtons to the corresponding number of dynes.
     * 
     * @param newton the number of newtons.
     * @pre. newton >= 0 && newton <= 100
     * @return the number of dynes corresponding to the given number of newtons.
     */
    public static int convert(int newton)
    {
	return newton * NewtonToDyne.DYNES_PER_NEWTON;
    }
}

Multiple choice question

Question 1 Consider the following code snippet.
int a = 0;
int b = 1;
Utility.swapper(a, b);
System.out.printf("%d %d", a, b);

Which of the following statements is correct?

A. The above snippet prints the string "1 0".
B. The above snippet prints the string "0 1".
C. What the snippet prints depends on the body of the swapper method.
D. None of the above.