Monday 18 March 2013

SCJP - 30 - Given Example


What is the result?

A. Compilation succeeds.
B. Compilation fails due only to an error on line 3.
C. Compilation fails due only to an error on line 4.

D. Compilation fails due only to an error on line 5.
E. Compilation fails due to errors on lines 3 and 5.
F. Compilation fails due to errors on lines 3, 4, and 5.

Answer:

A is correct, all of these array declarations are legal. Lines 4 and 5 demonstrate that arrays
can be cast.

B, C, D, E, and F are incorrect because this code compiles. (Objective 1.3)
==
class Zippy {
String[] x;
int[] a [] = {{1,2}, {1}};
Object c = new long[4];
Object[] d = x;
}


No comments:

Post a Comment