I'll move this thread to our SCJP forum, but not before answering your first question.

Eoin Brosnan wrote:Hi,
I am working my way through some SCJP questions and I have come across two that I don't understand.
First one if from ExamLab.

Which is valid:

Ok, I know why A&B are false, but the syntax for C&D&E is completely new to me. C is the only one that is true, but I have no idea why.

A is invalid because you either create an array with a size (new int[0]) or with its values ({}), not both.

B is invalid because it's impossible to only create an array without doing anything with it. I was actually a bit surprised by this, because it is possible to call "new Object();". Apparently the compiler is smart enough to see that an array without a reference is useless, whereas an object can still do things in its constructor.

C uses two "techniques". The first is create an array while immediately assigning its values: new int[][]{{1}}. Then its first element is accessed using [0]; the result is an int[] since the array itself is an int[][].

D tries to do the same, but the dimensions are wrong. new int[]{0} creates an array with one element with value 0. The first [0] returns that element, an int. The second [0] is invalid, since this is only allowed for arrays, not for ints.