public class IntPair
{
private int firstValue;
private int secondValue;
public IntPair(int first, int second)
{
firstValue = first;
secondValue = second;
}
public int getFirst()
{ return firstValue; }
public int getSecond()
{ return secondValue; }
public void setFirst(int a)
{ firstValue = a; }
public void setSecond(int b)
{ secondValue = b; }
}
Here are three different swap methods, each intended for use in a client program.
I public static void swap(int a, int b)
{
int temp = a;
a = b;
b = temp;
}
II public static void swap(Integer obj_a, Integer obj_b)
{
Integer temp = new Integer(obj_a.intValue());
obj_a = obj_b;
obj_b = temp;
}
III public static void swap(IntPair pair)
{
int temp = pair.getFirst();
pair.setFirst(pair.getSecond());
pair.setSecond(temp);
}
When correctly used in a client program with appropriate parameters, which method will swap two integers, as intended?
(A) I only
(B) II only
(C) III only
(D) II and III only
(E) I, II, and III