Arrays – Practice Questions and FRQ

Arrays

1 / 2

public static void mystery(int[] list) {
for (int i = 0; i < list.length / 2; i++) {
int j = list.length - 1 - i;
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
public static void main(String[] args) {
int[] array = {1, 3, 5, 7, 9};
mystery(array);
for (int val : array) {
System.out.print(val + " ");
}
}

2 / 2

What exception is thrown by the following code snippet?

int[] numbers = new int[5];numbers[10] = 50;System.out.println("Value: " + numbers[10]);

Your score is

The average score is 33%

0%

Scroll to Top