Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Questions 19 and 20 deal with the problem of swapping two integer values. Three

ID: 3921028 • Letter: Q

Question

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 ob- jects, and IntPair objects, where IntPair is defined as follows: public class IntPair private int firstValue private int secondValue: public IntPair(int firet, int second) firstValue first; secondValue aacond public int getFirsto return firetValue; public int getSecond) return secondValue; public void setFirst(int a) firstValue a; 1h publie void setSecond (int b) ( secondValue b;

Explanation / Answer

Answer

B) II only is correct, as we are creating a IntegerPair object using x and y values and sending the same to swap method where the exchange occurs and finally exchanged values are stored in x and y