Wednesday, 1 June 2016

Java Certification: To Cert or Not to Cert

Professional certification is always a bit of a controversial subject, with benefits vs. cost/time debated by those who are eligible.  With Oracle’s Java certifications, I hold the opinion that there are two primary audiences that stand to benefit:

  • Those who are starting a career in software. Solid work experience with demonstrable code is always going to be a top hiring consideration by potential employers.  However, in the absence of that, Java certifications are an objective way to demonstrate a base level of proficiency in a related skill.  With a junior programming position opportunity, where candidates have a limited work history, a certification could be the difference between staying in the resume pile and getting into the interview chair.  Similarly, if you have a solid work history, but are applying for a job that focuses on an API you haven’t used on a project, a certification could help bridge that gap in your resume.
  • Those who are looking to learn new skills, or for an objective verification of their subject matter expertise. Oracle has made an effort to ensure that their certifications reflect the skills & knowledge which are required in professional engagements.  If you’re new to a Java edition or API, studying for these exams can help establish a set of boundaries of what topics you really need to know.  If you already have experience with the subject, you can use these exams to verify that you do, in fact, know as much as you think you know.


Becoming an Oracle Certified Associate, Java SE 8 Programmer



A few years ago, Oracle revamped their Java certification paths. At that time, they introduced different levels of certification.  When following the Java programmer path, you are required to completed the “Associate” certification before others (such as “Professional” or “Master” level certifications).  There is one exception to this rule – if you’ve already completed previous Java certifications, they do have upgrade paths available.

There is one exam required for this certification: Java SE 8 Programmer I 1Z0-808.  To take this exam, you begin by purchasing a voucher from Oracle University.  After this purchase, you’re now able to register to take the exam at a proctored exam facility.  The exam contains a set of 77 multiple choice questions which contribute to your final score.  It is possible that there may be more questions added during your exam, however those are “unscored.”  Unfortunately, you are not told which questions are scored and which are unscored.  The entire exam must be completed within 150 minutes.

During the exam, you will be able to write down notes on materials provided by the center.  Absolutely no other notes may be brought into the testing room, and you will have to return the material they’ve provided upon completion of the exam.  At this point, you’ll likely be anxious to find out your scores, but the test center will not provide that information. Instead, you’ll need to wait for your score to be posted on Oracle’s CertView website.  If you complete the exam with a score of 65% or greater, you’ve passed and have earned the status of an Oracle Certified Associate, Java SE 8 Programmer.
For full details and to begin the registration process, go to Oracle University.
Just make sure that you are registering for the Java SE 8 Programmer I 1Z0-808 exam, as this page also lists earlier exams for SE 5/6 and SE 7.

Exam Tips


While the rules of the certification prohibit me from sharing specific test questions, I can give you some general tips that should help improve your score.
Read what’s actually written… not what you expect to be there.
A commonly heard suggestion is to first check to see if one of the answers is “This does not compile.”  The theory is, if that isn’t one of the available options, you don’t have to worry about the question trying to trick you with a sneaky compile error.  That is, of course, true, however, I believe it sets people up for lazy reading.  Let me give you an example.  What’s the output of the following code?

public class Person {  
    private String fullName = "Jason Shapiro";     

    public void Person() {
        fullName = "J. Shapiro";
    }
    public static void main(String[] args) {

        System.out.println( new Person().fullName );

    }

}

Let’s say test anxiety creeps in and your first thought is, “Hmm…  wasn’t there some rule that says I can’t access instance variables within a static method?  I know I’m accessing fullName by sending a message to Person, but it is inside of main…”  So, you quickly check the list of available options and note that “Does not compile” is not listed.  You breathe a sigh of relief, correctly assume this is legal, and quickly choose “J. Shapiro” since the constructor will be executed after fullName’s explicit initialization.  Unfortunately, that answer is wrong.  If you look carefully (and I’m sure some of you caught this), note that Person() is not a constructor.  It has a return value; therefore, it is a method.  So in fact, that method is never called, and the answer is “Jason Shapiro.”

Practice reading code with different formats.

There’s a general feeling that the more experience you have with Java, the easier these exams are.  While that is typically true, experienced developers often get used to a specific coding style.  When the style presented is different, it can present a challenge to the reader.  So what things can be different?   Use of whitespace and curly braces are the main culprits.  You should, in the very least, make sure you’re aware of the rules of when braces are required and when they’re optional.  For example, you may be used to a do…while loop like this:


do {
    System.out.println(i.next().fullName);
} while( i.hasNext() );


But you should also be used to reading it like this:

do System.out.println(i.next().fullName); while( i.hasNext() );

Similarly, you may be familiar with multi dimensional arrays such as:

int[][][] studentIdsByLocation = new int[20][83][2];

…but are you aware that the following syntax is also legal?

int[] studentIdsByLocation[][] = new int[20][83][2];

Remember that all scored questions are worth one point.  Even the really hard ones!

You have 150 minutes to answer all of the questions, so if you find that you’re taking far too long on a single question, mark it as one to come back to at the end. Better to miss one point on a hard question than possibly run out of time on questions you know the answers to!

Follow Your Orders!

There are many rules of ordering and precedence in Java.  After years of coding, it’s easy to forget all but the most common examples.  The first one to remind yourself about is the order of operator precedence.  Create a random expression with multiple operators, and test yourself to see if you can determine the correct results.  You might remember that multiply happens before addition, but how does that all fit in with post and pre increment operators?  For example, what are the values of x and y after running this code:

int x = 3;
int y = 5;
y = y++;
y = y++;
y = y++;
x = 4 * ++y - 3 + x * y;
x = x++;

If you said anything other than x = 39 and y = 6, you will want to spend some more time on this topic.  In this particular example, the lines y = y++; and x = x++; really don’t have any effect.  Both are using the post increment operator, so the current value is returned and assigned to the variable, thus overwriting the increment.
Another related topic to be familiar with is the order of class loading and object instantiation.  You should be familiar with when static initialization blocks are called (and that they’re only called once per life of the class), and how they flow with instance initialization blocks, inline variable initializations, and constructors.  Create a three level object hierarchy chain (such as Person -> Employee -> Consultant), and add all of these initialization structures with print statements.  Then instantiate the most specific type (Consultant) – twice.  Try another example where you just create a Consultant, Employee, and Person variables (leave them null). Which print statements are called?  Memorize this process of class loading and instantiation.
Finally, be familiar with the order of selection when invoking an overloaded method with a primitive argument.

If we have the following methods:

public void computeIt(Long val) { }
public void computeIt(int... val) { }
public void computeIt(double val) { }

… and make the following method call:

obj.computeIt(5);

You should know that the method that declares the double parameter will be invoked.  If you didn’t, learn the following order of selection:

  1. An exact primitive match with the method parameter has the highest precedence of method selection.
  2. If an exact primitive type isn’t available for byte, short, char, int, or long:
    1. The next larger size whole number primitive available (byte, short, int, and long).
    2. The smallest size decimal primitive available (float, double).
  3. … and for float:
    1. The double primitive.
  4. Exact wrapper class (in this case, Integer).
  5. Varargs of exact primitive type.
  6. If varargs for the exact primitive isn’t available for byte, short, char, int, or long:
    1. The next larger size whole number varargs available (byte, short, int, and long).
    2. The next smallest size decimal varargs available (float, double).
  7. … and for float:
    1. The double varargs.
  8. Finally: the varargs of exact wrapper class.

For many of you, that’s probably a bit more complicated than you remember.  Spend some time defining and calling overloaded methods with primitives, varargs, and wrapper classes to see what’s actually invoked with different arguments.

Immutability and Capturing Return Values

Of the classes you’re expected to know for the exam – all of which are listed here.
You must know which are “immutable.”  Strings and the classes from the java.time package which are included in this exam, are all immutable.  That means when you call methods on them which appear to modify their content, you must capture their return value.  For example, the following code might be thrown into a larger question.

String fullName = "Jason Shapiro";
fullName.toUpperCase();
System.out.println(fullName);

If you’re reading too fast, you may forget that Strings are immutable, and therefore, incorrectly assume that fullName is now “JASON SHAPIRO.”  If the code had been written as follows, “JASON SHAPIRO” would have been the correct output:

String fullName = "Jason Shapiro";
fullName = fullName.toUpperCase();
System.out.println(fullName);

This is probably a rule you’re already familiar with, but test anxiety combined with a time limit makes it easy to miss improper code due to immutability.  So, before taking the exam, remind yourself which objects are immutable and always make sure to note whether or not the return value is being captured.