Write a method called switchThem that accepts two integer arrays as parameters and switches the contents of the arrays. Take into account that the arrays may be of different sizes.
What will be an ideal response?
```
public void switchThem(int[] first, int[] second)
{
if (first.length == second.length)
{
// copy contents of first into temp
int [] temp = new int[first.length];
for (int i =0; I < first.length; i++)
temp[i] = first[i];
//copy contents of second into first
for (int i =0; I < first.length; i++)
first[i] = second[i];
//copy contents of temp into second
for (int i =0; I < first.length; i++)
second[i] = temp[i];
}
else
System.out.println("Arrays are of different sizes");
}
```
You might also like to view...
Which of the following attacks is used to overload the switch content addressable memory (CAM) table?
a. ARP poisoning b. ARP spoofing c. MAC flooding d. Session hijacking
(int)('a' + Math.random() * ('z' - 'a' + 1)) returns a random number __________.
a. between 0 and (int)'z' b. between (int)'a' and (int)'z' c. between 'a' and 'z' d. between 'a' and 'y'