DEV Community

ExamCert.App
ExamCert.App

Posted on

The 5 Java Traps in the OCA 1Z0-808 That Catch Everyone (Including Me)

I've been writing Java professionally for 6 years. I use Spring Boot daily. I can debug a NullPointerException in my sleep.

I scored 62% on my first 1Z0-808 practice exam.

The OCA (Oracle Certified Associate) Java SE 8 exam doesn't test whether you can write Java. It tests whether you understand the language specification — all the weird corner cases, implicit behaviors, and gotchas that your IDE usually handles for you.

Here are the 5 traps that got me, and will probably get you too.

Trap 1: String Pool and == vs .equals()

You know this one, right? Use .equals() for Strings, == for primitives. Easy.

Except the exam will show you this:

String a = "hello";
String b = "hello";
System.out.println(a == b); // true — wait, what?
Enter fullscreen mode Exit fullscreen mode

And then this:

String a = new String("hello");
String b = "hello";
System.out.println(a == b); // false
Enter fullscreen mode Exit fullscreen mode

The String pool makes == return true for string literals, but false when new String() creates a separate object.

The rule: == compares references. .equals() compares values. String literals are pooled. new String() bypasses the pool. Know this cold.

Trap 2: Array Initialization vs Declaration

Quick — is this valid?

int[] arr = new int[3]{1, 2, 3};
Enter fullscreen mode Exit fullscreen mode

Nope. You can't specify both size AND provide values. It's either:

int[] arr = new int[3]; // size only
int[] arr = {1, 2, 3}; // values only
int[] arr = new int[]{1, 2, 3}; // also values only
Enter fullscreen mode Exit fullscreen mode

Trap 3: The Switch Statement Fallthrough

int x = 2;
switch(x) {
    case 1: System.out.print("A");
    case 2: System.out.print("B");
    case 3: System.out.print("C");
    default: System.out.print("D");
}
Enter fullscreen mode Exit fullscreen mode

Output: BCD — Not B. Because without break statements, switch cases fall through.

Trap 4: Variable Scope in Loops

Variables declared in a try block aren't accessible in the catch or finally blocks. Variable shadowing rules trip people up constantly.

Trap 5: Operator Precedence and Short-Circuit Evaluation

int x = 5;
boolean result = (x > 3) || (++x > 5);
System.out.println(x); // 5, not 6
Enter fullscreen mode Exit fullscreen mode

Because || short-circuits: the left side is true, so ++x never executes.

How to Actually Prepare

  1. Stop reading tutorials. Start reading the Java Language Specification for exam topics.
  2. Write code for every edge case.
  3. Drill practice questions daily. I used 1Z0-808 practice questions on ExamCert — they specifically test these edge cases.
  4. Take timed practice exams. 150 minutes for 77 questions.

Exam details: 77 questions, 150 minutes, passing 65%, cost $245 USD.

Respect the exam. Practice with ExamCert's OCA Java practice tests before you book.

Top comments (0)