ACTUAL Exam Questions and CORRECT
Answers
T/F: Is it possible to have an array of more than 2 dimensions (2D) in Java? - CORRECT
ANSWER - Yes, true Java does not limit you to two-dimensional arrays and allows an
infinite amount of dimensions.
Which of the following array declarations are valid?
a.int[] myArray = new int[2];
b.int myArray[] = new int[2];
c.int myArray = new Array(2);
d.int[] myArray = [1,2]; - CORRECT ANSWER - A and B are valid declarations. C is not
valid Java code.
What do you expect the output of the following code segment to be?
int[] myArray = new int[5];
myArray[5] = 1; - CORRECT ANSWER - This code throws an IndexOutOfBounds
exception. Remember that sincearray indexes start at 0 in Java, an array of size 5 has valid
indexes 0-4.
What happens if an exception occurs and is not caught? - CORRECT ANSWER - The
program will terminate and output a stack trace.
Which of the following exceptions are unchecked?a.ClassNotFoundException
b.IndexOutOfBoundsException
c.RuntimeException
d.NoSuchMethodException - CORRECT ANSWER - RuntimeException and all of its
subclasses are unchecked. Therefore,IndexOutOfBounds is also unchecked.
Checkedexceptionsarecheckedatcompile-time,notruntime.