Sunday 17 March 2013

SCJP - 7 -Which are legal declarations? (Choose all that apply.)


7. Which are legal declarations? (Choose all that apply.)

A. short x [];
B. short [] y;
C. short[5] x2;
D. short z2 [5];
E. short [] z [] [];
F. short [] y2 = [5];

Answer:

A, B, and E are correct array declarations; E is a three dimensional array.
C, D, and F are incorrect, you can't include the size of your array in a declaration unless
you also instantiate the array object. F uses invalid instantiation syntax. (Objective 1.3)

No comments:

Post a Comment