IntelliJ Java IDE
The moose likes Mock Exam Errata and the fly likes Sun's New Sample Q&A. Java 2 Question 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Mock Exam Errata
Reply Bookmark "Sun Watch "Sun New topic
Author

Sun's New Sample Q&A. Java 2 Question 1

Bob Kerfoot
Ranch Hand

Joined: Oct 01, 2000
Posts: 47
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
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
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
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
 
 
subject: Sun's New Sample Q&A. Java 2 Question 1
 
Threads others viewed
Sun sample paper -#2
Sun Sample queston #1
System.arraycopy
email to Sun:the new programmer test question & answers
doubt in new exam question
MyEclipse, The Clear Choice