| By Naveen Gabrani | Article Rating: |
|
| October 6, 2004 12:00 AM EDT | Reads: |
28,337 |
Related Links:
Have you looked at the certificate that your neighbor has so proudly displayed in his or her office? Have you ever wondered if getting certified in Java is worth the time and effort? This article argues the case for certification and provides information on how to prepare for the SCJP exam.
In today's tough job market, a certification from an established vendor like Sun can act as one more selling point in your résumé. All else being equal, most employers will prefer a certified candidate. Certification alone does not guarantee a job. But it acts as a reassurance to a prospective employer that the candidate at least understands the basics of Java. The certification is especially useful if you are a new graduate or if you're looking for your first job in Java.
Perhaps even more useful than getting the certificate is the learning involved in preparing for the exam. The certification enforces discipline. Most people are too busy with their jobs to have time to stay up-to-date on the latest technologies. Preparing for certification helps bring focus and discipline, and lets you update your skills on a specific technology. The certification exams from Sun are industry standard and well recognized in the industry.
Sun offers seven Java-related certification exams:
- Sun Certified Java Programmer (SCJP)
- Sun Certified Java Developer (SCJD)
- Sun Certified Web Component Developer (SCWCD)
- Sun Certified Business Component Developer (SCBCD)
- Sun Certified Mobile Application Developer (SCMAD)
- Sun Certified Enterprise Architect (SCEA)
- Sun Certified Developer for Java Web Services (SCDJWS)
A quick overview of each of these exams is provided in the following.
Scheduling the SCJP Exam
All the online exams are conducted at the Sylvan Prometric Centers throughout the world. To schedule a test:
- Visit http://suned.sun.com/US/catalog/courses/CX-310-035.html. Add the product to the shopping cart and purchase it.
- Visit www.prometric.com. Locate a Prometric site that suits you. After this you can schedule an exam through the site.
The exam objectives define the course contents for the exam. The topics include declarations and access control, flow control, assertions and exception handling, garbage collection, language fundamentals, operators and assignments, overloading, overriding and object orientation, threads, fundamental classes, and collections.
The exam covers some of the facets of Java that are sometimes unknown even to a seasoned Java programmer. So some exam-specific preparation is required even for experienced Java programmers.
Sample Questions
Question 1 (Declaration and access control)
Which of the following are valid constructors within a class Test? Select the two correct answers.
A. test() { }
B. Test() { }
C. void Test() { }
D. private final Test() { }
E. abstract Test() { }
F. Test(Test t) { }
G. Test(void) { }
Answer: B and F. A constructor must have the same name as the class. The name of the class is Test. Since Java is case sensitive, test is different than Test, hence option A is not valid. The constructor must not return any value, so option C is incorrect. A constructor cannot be declared abstract or final. Hence D and E are incorrect answers. Since taking a void argument is illegal in Java, G is also illegal.
Question 2 (Flow control)
What is printed when the following gets compiled and run? Select the two correct answers.
1. public class example {
2. public static void main(String args[]) {
3. int x = 0;
4. if(x > 0) x = 1;
5.
6. switch(x) {
7. case 1: System.out.println(1);
8. case 0: System.out.println(0);
9. case 2: System.out.println(2);
10. break;
11. case 3: System.out.println(3);
12. default: System.out.println(4);
13. break;
14. }
15. }
16. }
A. 0
B. 1
C. 2
D. 3
E. 4
Answer: A and C. The main method initialized x to 0. The if condition at line 4 returns false, so x remains zero at the beginning of the switch statement. The value of x matches with case 0. Hence 0 gets printed. Since there is no break statement after this, 2 also get printed. The break statement after case 2 leads to the control coming out of the switch statement. Hence 0 and 2 are the only numbers that get printed.
Question 3 (Assertions and exception handling)
What happens when the following code is compiled and run? Select the one correct answer.
1. public class example {
2. public static void main(String args[]) {
3. for(int i = 1; i < 4; i++)
4. for(int j = 1; j < 4; j++)
5. if(i < j)
6. assert i!=j : i;
7. }
8. }
A. The class compiles and runs, but does not print anything.
B. The number 1 gets printed first with AssertionError.
C. The number 2 gets printed first with AssertionError.
D. The number 3 gets printed first with AssertionError.
E. The program generates a compilation error.
Answer: A. The if condition returns true, if i is less than j. The assert statement performs a check whether i is equal to j. Since i will never be equal to j, the assert statement will always return true. Hence the AssertionError does not get generated. So B, C, and D are incorrect.
Question 4 (Garbage collection)
At what stage in the following method does the object initially referenced by s become available for garbage collection? Select the one correct answer.
1. void method X() {
2. String r = new String("abc");
3. String s = new String("abc");
4. r = r+1;
5. r = null;
6. s = s + r;
7. }
A. Before statement labeled 4
B. Before statement labeled 5
C. Before statement labeled 6
D. Before statement labeled 7
E. Never
Answer: D. After statement 3, r and s are pointing to two different memory locations both containing "abc". After statement 4, the memory location to which r was pointing is available for garbage collection. After statement 6, s now points to a different location. The memory block that s was pointing to that contained "abc" is now available for garbage collection.
Question 5 (Language fundamentals)
Which of these are legal identifiers? Select the three correct answers.
A. number_1
B. number_a
C. $1234
D. -volatile
Answer: A, B, and C. In Java, each character of an identifier can be either a digit, letter, underscore, or a currency symbol. The first character cannot be a digit. Since - is not a valid character in an identifier name, D is incorrect.
Question 6 (Language fundamentals)
What happens when the following program is compiled and executed with the command - java test? Select the one correct answer.
1. class test {
2. public static void main(String args[]) {
3. if(args.length > 0)
4. System.out.println(args.length);
5. }
6. }
A. The program compiles and runs but does not print anything.
B. The program compiles and runs and prints 0.
C. The program compiles and runs and prints 1.
D. The program compiles and runs and prints 2.
E. The program does not compile.
Answer: A. The above program is a legal Java file. No arguments are passed to the program, as the command line just says java test. test here is the name of the class. The args array does not contain any elements. Since args.length is zero, the program does not print anything.
Question 7 What happens when the following program is compiled and run? Select the one correct answer.
1. public class example {
2. int i[] = {0};
3. public static void main(String args[]) {
4. int i[] = {1};
5. change_i(i);
6. System.out.println(i[0]);
7. }
8. public static void change_i(int i[]) {
9. i[0] = 2;
10. i[0] *= 2;
11. }
12. }
A. The program does not compile.
B. The program prints 0.
C. The program prints 1.
D. The program prints 2.
E. The program prints 4.
Answer: E. The example is a legal Java class so A is incorrect. When array is passed as an argument, Java treats it as a call by reference. When the method change_i updates i[0], the first element of the array is directly getting modified. This element is set to 4 in change_i. This change in the value of i[0] is available in the main method also. Hence 4 gets printed.
Question 8 (Operators and assignments)
In the following class definition, which is the first line (if any) that causes a compilation error? Select the one correct answer.
1. public class test {
2. public static void main(String args[]) {
3. char c;
4. int i;
5. c = 'A';
6. i = c;
7. c = i + 1;
8. c++;
9. }
10. }
A. The line labeled 5
B. The line labeled 6
C. The line labeled 7
D. The line labeled 8
E. All the lines are correct and the program compiles
Answer: C. "A" is a character. So assigning "A" to c in statement 5 is perfectly valid. Assigning a character to integer is also valid and does not require a cast. Thus the statement labeled 6 does not generate a compilation error. It's not possible to assign an integer to a character without a cast. Hence the statement 7 generates a compilation error.
Question 9 (Objects)
Which of the following are true? Select the three correct answers.
A. A static method may be invoked before even a single instance of the class is constructed.
B. A static method cannot access nonstatic methods of the class.
C. An abstract modifier can appear before a class or a method but not before a variable.
D. The final modifier can appear before a class or a variable but not before a method.
E. A synchronized modifier may appear before a method or a variable but not before a class.
Answer: A, B, and C. A and B are correct statements about the behavior of static methods. The abstract modifier may appear before a method or a class, but not before a variable, so C is also correct. A final modifier may appear before a method, a variable or before a class. Hence D is incorrect. A synchronized modifier cannot come before a variable so E is also incorrect.
Question 10 (Collections)
Which of these are interfaces in the collection framework? Select the two correct answers.
A. HashMap
B. ArrayList
C. Collection
D. SortedMap
E. TreeMap
Answer: C and D. Collection and SortedMap are examples of interfaces in the collection framework. HashMap. ArrayMap and TreeMap are examples of general purpose implementations for some of the collection interfaces.
Question 11 (Fundamental classes)
What gets written on the screen when the following program is compiled and run? Select the one correct answer.
1. public class test {
2. public static void main(String args[]) {
3. int i;
4. float f = 2.3f;
5. double d = 2.7;
6. i = ((int)Math.ceil(f)) * ((int)Math.round(d));
7.
8. System.out.println(i);
9. }
10. }
A. 4
B. 5
C. 6
D. 6.1
E. 9
Answer: E. The method ceil returns the smallest double value equal to a mathematical integer that is not less than the argument. Hence ceil(2.3f) returns 3. The round method round returns the integer closest to the argument. Hence round(2.7) returns 3. Multiplying the two numbers returns 9.
Resources for Preparing for SCJP
There are a large number of mock exams available on the Web. The links to the best of these is included below.
The three standard books on Java certification are:
Any one of these will be sufficient for you to prepare for the exam.
Besides the numerous free mock exams available on the Web, there are a few commercial exam simulators also available. Some of the main ones are:
SIDEBAR
Other Java Certifications
Though Sun's Java certification is an industry standard, there is another certification exam on Java technology offered by Brainbench (www.brainbench.com/xml/bb/common/testcenter/ taketest.xml?testId=118) that costs $49.95.
SIDEBAR 2
Retaking the Exam
In case you fail to clear the exam on the first attempt, you can take the exam again. You would need to buy another voucher from Sun. Sun also requires that you wait for two weeks before retaking the exam.
SIDEBAR 3
After Clearing the Exam
After clearing the exam, Sylvania Prometric will provide you with a score sheet highlighting your scores in various sections. You should receive a formal certificate from Sun. This may take 8-10 weeks. If you don't receive the certificate within this time frame, contact them. You may also check your certification results online at www.galton.com/~sun. This site has a database of all candidates who have cleared Sun's certifications.
Published October 6, 2004 Reads 28,337
Copyright © 2004 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Naveen Gabrani
Naveen Gabrani is a project manager in Computer Sciences Corporation (CSC), India. He also runs a Java certification site www.javaprepare.com.
![]() |
Rafiq 10/11/04 10:04:17 PM EDT | |||
nice one. will be useful for the needy. |
||||
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Kindle 2 vs Nook
- Why IBM’s Server Chief Got Busted
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Journal Opens "Readers' Choice Awards" Nominations
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Industry Experts Discuss the State of Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- It's the Java vs. C++ Shootout Revisited!
- The End of IT 1.0 As We Know It Has Begun
- An Introduction to Abbot
- Java Kicks Ruby on Rails in the Butt
- Interviewing Java Developers With Tears in My Eyes
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- 1st Annual Government IT Expo: Call for Papers Deadline July 15
- How to Diagnose Java Resource Starvation
- REA Is Where RIA Becomes the Norm
- Kindle 2 vs Nook
- Anatomy of a Java Finalizer
- Why IBM’s Server Chief Got Busted
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- The i-Technology Right Stuff
- JavaServer Faces (JSF) vs Struts
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- What's New in Eclipse?



























