1. Given: public class ArrayTest { public static void main (String[] args) {i Object[] ov; String[] sa = { "Green", "Blue", "Red" }; ov = sa; System.out.println("Color = " + ov[1]; } } What is the result? A. fails to compile B. prints Color=Blue C. prints Color=Green D. generates an exception at runtime Sun indicates that the answer should be B. However, the correct answer is A because the stray i following the opening curly prevents this from compiling successfully. Looks like it's probably a typo but I sent the same comment to who2contact@central.sun.com anyway. Bob Kerfoot SCJP - 92%
bill bozeman
Ranch Hand
Joined: Jun 30, 2000
Posts: 1070
posted
0
I think you are right. Without the i, it would be B, but with the i, which I agree is probably a typo, it wouldn't compile. When I first saw it, I thought you made the typo
greg clarke
Greenhorn
Joined: Oct 06, 2000
Posts: 25
posted
0
I fear not Bill. Look for the missing parenthesis in the output statement: System.out.println("Color = " + ov[1]; So, remove the "i" and it still won't compile. Two typos in one question!? Bob - how did Sun indicate to you the intended answer?
Bob Kerfoot
Ranch Hand
Joined: Oct 01, 2000
Posts: 47
posted
0
Greg, Sun never got back to me but they still list "B. prints Color=Blue" as the correct answer at the web site. The missing ")" is definitely also a problem. Hopefully the real exam questions are cleaner than those in the new sample. Bob Kerfoot - SCJP