Welcome!

Java Authors: Maureen O'Gara, Dana Gardner, Miko Matsumura, John Ryan, Loraine Antrim

Related Topics: Java

Java: Article

Java Certification

Java Certification

Related Links:

  • Java Certification and I

    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)
    Sun also has another new exam - Web Services Certification (SCDJWS). This is currently in beta and is likely to be launched in the near future.

    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:

    1. Visit http://suned.sun.com/US/catalog/courses/CX-310-035.html. Add the product to the shopping cart and purchase it.
    2. Visit www.prometric.com. Locate a Prometric site that suits you. After this you can schedule an exam through the site.
    Course Contents
    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.

     

  • Sun's sample questions for the programmer exam: http://suned.sun.com/US/certification/
  • JavaRanch has extremely popular discussion forum on Java certifications and other topics: www.javaranch.com/certfaq.jsp
  • Javaprepare has two mock exams, a tutorial and FAQ on Java certification: www.javaprepare.com
  • Dan Chisholm's Web site has high-quality mock exams for the SCJP 1.4 exam. It has more than 350 questions. It also has mock exam questions by topic: www.danchisholm.net
  • Javacertificate.com has a large pool of questions and some are organized by objectives: www.javacertificate.com

    The three standard books on Java certification are:

  • Mughal, K. A., Rasmussen, R. (2003). A Programmer's Guide to Java Certification. Addison Wesley Professional.
  • Sierra, K., and Bates, B. (2002). Sun Certified Programmer & Developer for Java 2 Study Guide. McGraw-Hill Osborne Media.
  • Roberts, S., and Heller, P., (2003). Complete Java 2 Certification Study Guide, Fourth Edition. Sybex Inc.

    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:

     

  • Practice exam offered by Sun: http://suned.sun.com
  • J@Whiz is a test simulator on the latest pattern of SCJP2, with 700 questions (12 Tests) at $59.95 or India Rs. 495: www.whizlabs.com
  • JQPlus offers an exam simulator based on the new certification pattern: www.enthuware.com/jqplus
  • JCertify provides an exam simulator that costs $69.95: http://enterprisedeveloper.com/jcertify

    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.

    Related Links:
  • Java Certification and I
  • About Naveen Gabrani

    Naveen Gabrani is a project manager in Computer Sciences Corporation (CSC), India. He also runs a Java certification site www.javaprepare.com.

    Comments (1) View Comments

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    Most Recent Comments
    Rafiq 10/11/04 10:04:17 PM EDT

    nice one. will be useful for the needy.