Questions 19 and 20 deal with the problem of swapping two in
Questions 19 and 20 deal with the problem of swapping two integer values. Three methods are proposed to solve the problem, using primitive int types, Integer objects, and IntPair objects, where IntPair is defined as follows: 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 setSecond(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 onj_a, Integer obj_b) {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 I only II only III only II and III only I, II, and III
Solution
D) II and III only
In code II swap is done by exchanging integer objects
In code III swap done by exchanging first and second values of IntPair using temp int variable.
