Sunday 17 March 2013

SCJP - 9 - Given Example


Which statements are true? (Choose all that apply.)
A. The code compiles.
B. If only line 1 is removed the code compiles.
C. If only line 3 is removed the code compiles.
D. If only line 5 is removed the code compiles.
E. If lines 1 and 3 are removed the code compiles.
F. If lines 1, 3 and 5 are removed the code compiles.

Answer:
D and F are correct. Line 5 is the only line that will not compile, because enums cannot be
local to a method.
A, B, C and E are incorrect based on the above.
==
enum A { A }
class E2 {
enum B { B }
void C() {
enum D { D }
}
}

No comments:

Post a Comment