If an array in Java has a size (or length) of N, what is the index number of its final element?
A.
N
B.
0
C.
N - 1
D.
N + 1
Which of the following is the correct syntax for declaring an integer array with a fixed size of 5 elements in Java?
A.
int numbers = new int[5];
B.
int[] numbers = new int(5);
C.
int numbers[5];
D.
int[] numbers = new int[5];
What exception is thrown at runtime if you attempt to access an array element using an index that is negative or greater than or equal to the array's length?
A.
ArrayIndexOutOfBoundsException
B.
NullPointerException
C.
IllegalArgumentException
D.
IndexOverflowException
How do you properly determine the number of elements an array holds in Java?
A.
Using the sizeof() operator
B.
Calling the array.size() method
C.
Using the array.length property
D.
Using the array.count() method
Using Java's java.util.Random class, which expression correctly generates a random integer between 1 and 100
A.
random.nextInt(100)
B.
random.nextInt(100) + 1
C.
random.nextInt(101)
D.
random.nextInt() % 100