Professional Documents
Culture Documents
Khalid Mughal-Guide To Java Cert Javazone2005
Khalid Mughal-Guide To Java Cert Javazone2005
5 Exam
Khalid Azim Mughal Department of Informatics University of Bergen khalid@ii.uib.no http://www.ii.uib.no/~khalid Version date: 2005-09-04
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
1/32
Talk Overview
Java Technology Certification Overview (3 min.) Sun Certified Programmer for Java 2 Platform 1.5 (SCJP 1.5) Exam: (3 min.) Overview of the Objectives of the SCJP 1.5 Exam (4 min.) Code Scenarios to illustrate the topics on the exam (30 min.) Preparing for the Exam (3 min.) Resources for the New Exam (2 min.)
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
2/32
http://www.sun.com/training/certification/java/index.html
JavaZone 2005, Oslo, Norway. Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam 3/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
4/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
5/32
Information for taking the exam in Norway: https://www.suntrainingcatalogue.com/eduserv/client/welcome.do?l=en_NO Contact one of the Thomson Prometric test centers in Norway when you are ready to take the exam. http://www.register.prometric.com/Menu.asp On passing the exam, Sun will send a certificate by mail.
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
6/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
7/32
The exam program A test run before the actual exam Presents a set of randomly-selected questions one at a time through a graphical user interface. Ability to navigate back and forth through the questions. Use the EXHIBIT-button to open the code scenario in a separate window. After the completion of the exam: An indication of pass or fail The total score Pass score is 59% (43 of 72). Questions weighted equally. No points for partially correct answers. Score on each of the categories of the objectives. The test program will not divulge which questions were answered correctly or the answers to the questions asked.
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
8/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
9/32
Focus on language usage tested through code scenarios, i.e. be able to read, evaluate, and troubleshoot code.
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
10/32
OBJECTIVE
03.01 01.05 01.01, 01.03 02.02 06.04 06.03 03.05 01.01 03.01 01.04
Static import
StringBuilder class
Var-args
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
12/32
OBJECTIVE
06.05 06.05 03.03 02.06 03.02, 03.03 03.05 01.06 05.05 07.05 01.04 03.04 05.01 07.04
Constructor and Deserialization Exception categorization File I/O Formatting Instantiating nested classes is-a, has-a relationships JAR files, CLASSPATH environment variable JavaBeans Standard Internationalization: Locales Object-oriented (OO )concepts Programmatic Garbage Collection (GC)
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
13/32
TOPICS OMITTED
Low-level (lexical) and esoteric language details
Bitwise operators Shift operators Math class
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
14/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
15/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
16/32
Fill in the blanks in the above code so that it compiles without errors and warnings, and prints "42 38 30 25 ". Only the following code fragments can be used, multiple times if necessary, to fill in the blanks. <Belt> Belt compare b1 b1.size <CraftingBelts> CraftingBelts compareTo b2 b2.size <Comparator> Comparator sort b b.size
bList.values()
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
17/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
18/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
19/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
20/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
21/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
22/32
public static void main(String[] args) { new GMI().doCalling(); } public void doCalling() { // (1) Insert code here. } } Which method declaration when inserted at (1) will result in the above code to compile without errors and warnings? Select the one answer. (a) (b) (c) (d) (e) (f) (g) GMI.genericStaticMethod(); <String>genericStaticMethod(); GMI.<String>genericStaticMethod (); genericInstanceMethod(); this.genericInstanceMethod(); <String>genericInstanceMethod(); this.<String>genericInstanceMethod ();
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
23/32
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
24/32
Enums
Q9 Given: enum Meal { BREAKFAST(8), // (1) Insert code here. DINNER(18); Meal(int hh) { this.hh = hh; } private int hh; public int getHour() { return this.hh; } public void setHour(int hh) { this.hh = hh; } } public class MealClient { public static void main(String[] args) { System.out.println(Meal.LUNCH + " served at " + Meal.LUNCH.getHour()); } } Which code when inserted at (1) will result in the program to compile and print "LUNCH served at 13"? Select the one correct answer. (a) (b) (c) (d) (e) LUNCH(0) { hh = 13; }, LUNCH(0) { this.hh = 13; }, LUNCH(0) { this.setHour(13); }, LUNCH(0) { public int getHour() { return (BREAKFAST.hh + DINNER.hh)/2; } }, None of the above code will produce the specified output.
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
25/32
Covariant return
Q10 Given: class A {} class B extends A {} class C extends B {} class X { public B getIt() {return new B();} } class Y extends X { // (1) Insert code here. } Which methods when inserted independently at (1) will cause the above code to compile without errors or warnings? Select the 2 correct answers. (a) (b) (c) (d) (e) public public public public public C B A A C getIt() getIt() getIt() getIt() getIt() { { { { { return return return return return new new new new new C(); C(); C(); B(); B(); } } } } }
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
26/32
// // // // //
// (6)
Which statement is true about the program? (a) The values in the array initialization block at (1) are not assignable to elements of a Character array. (b) The operands in the expression iRef < version.length at (3) have incompatible types. (c) The operand of the ++ operator at (4) cannot be applied to a value of Integer type. (d) The type of the switch expression at (5) cannot be Integer. (e) The type of the index in the expression version[iRef] at (6) cannot be Integer. (f) The above code will compile and print: 0: 1 2: 5 (g) None of the above.
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
27/32
for(:) loop
Q12 Given: import java.util.*; import static java.lang.System.out; public class Looping { public static void main(String[] args) { List<Double> versions = new ArrayList<Double>(); versions.add(1.0); versions.add(1.5); versions.add(2.0); for (Double v : versions.values()) { v = v + 0.5; } out.println(versions); } } Which statement is true about the program? (a) The code will compile and print: [1.5, 2.0, 2.5] (b) The code will compile and print: [1.0, 1.5, 2.0] (c) The code will not compile.
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
28/32
Var-args
Q13 Given: class Arrrrg { public static void main(String... args) { doIt(1); doIt(1,2); } // (1) Insert code here. } Which method declaration when inserted independently at (1) will result in the above code to compile and execute normally? Select the two correct answer. (a) (b) (c) (d) (e) (f) (g) static void doIt(int... params) { } static void doIt(int[] params) { } static void doIt(int params...) { } static void doIt(int... params, int i) { } static void doIt(int j, int... params) { } static void doIt(int j, int... params[]) { } The code will not compile regardless of which method declaration is inserted.
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
29/32
RESOURCES
1. James Gosling, Bill Joy, Guy Steele, Gilad Bracha: The Java Language Specification, 3/e, Addison-Wesley Professional, 2005, ISBN: 0321246780 See also JLS Maintenance Page at http://java.sun.com/docs/books/jls/jls-maintenance.html. 2. Gilad Bracha. Generics in the Java Programming Language, July 2004. (http:// java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf) 3. Ken Arnold, James Gosling, David Holmes: Java Programming Language, 4/e, Addison Wesley Professional, 2006, ISBN: 0-321-34980-6 4. Katherine Sierra, Bert Bates: SCJP Sun Certified Programmer for Java 2 Platform 5 Study Guide (Exam 310-055), McGraw-Hill Osborne , 2005, ISBN: 0072253606
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
31/32
Good luck! You will need it! The exam is not a joke! Comments? Questions? Suggestions? :-)
Cracking the New Sun Certified Programmer for Java 2 Platform 1.5 Exam
32/32