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 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;

Solution

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

 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 o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site