Show the output of the following two programs:
(a)
public class Test {
public static void main(String[] args) {
int number = 0;
int[] numbers = new int[1];
m(number, numbers);
System.out.println("number is " + number
+ " and numbers[0] is " + numbers[0]);
}
public static void m(int x, int[] y) {
x = 3;
y[0] = 3;
}
}
(b)
public class Test {
public static void main(String[] args) {
int[] list = {1, 2, 3, 4, 5};
reverse(list);
for (int i = 0; i
System.out.print(list[i] + " ");
}
public static void reverse(int[] list) {
int[] newList = new int[list.length];
for (int i = 0; i
newList[i] = list[list.length - 1 - i];
list = newList;
}
}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.