Consider the following program that uses the IntPair class p

Consider the following program that uses the IntPair class: public class TestSwap {public static void swap(IntPair pair)} lnt temp - pair.getFlrst (); pair. setFi rat (pair.getSecond()); pair.setSecond(temp);} public static void aain(String[] args) {int x = 8, y - 6;}/* code to swap x and y */}} Which is a correct replacement for/* code to swap x and y */I IntPair iPair - now IntPair(x,y); awap(x, y); x - iPair.getFirst(); y - iPair.getSecond(); II IntPair IPair = new IntPair(x, y); swap(iPair); x = iPair.getFirst(); y - iPair.getSecond(); III IntPair iPair = new IntPair(x, y); swap(iPair); x = iPair.setFirst(); y = iPair. setSecond(); I only II only III only II and III only None is correct.

Solution

answer is option (b) II only

because here we assigns values to x and y variables,for that we have to get values of first and second values.therefor those two values are accessing using getFirst() and getSecond() methods.

******************************END******************PLS GIVE ME GOOD RATING*****************************************

 Consider the following program that uses the IntPair class: public class TestSwap {public static void swap(IntPair pair)} lnt temp - pair.getFlrst (); pair. se

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site