Java Certification Study Tool

Your interactive OCP 21 prep — challenges, quizzes, and a stopwatch for your brain.

20+ Code Challenges 12 OCP-style Quizzes 3 Chapter Sections

A 45-second tour of everything you can do. Let me show you.

Java Certification Study Tool
✓ Solved: 0 ✗ Given up: 0 Total: 20

Declaring a var

Complete the program so it prints 42.

public class Demo {
    public static void main(String[] args) {
        var answer = 6 * 7;
        System.out.println(answer);
    }
}
✓ Passed Expected output matched
42

The Stuck Post-Increment

This code should print 6 but prints 4. Fix it.

public class IncrementTest {
  public static void main(String[] args) {
    int pig = 4;
    pig = pig++;
    pig = pig++;
    System.out.println(pig);   // prints 4 :(
  }
}
SOLUTION REVEALED Red lines were the trap — green lines are the fix.
public class IncrementTest {  public static void main(String[] args) {    int pig = 4;-   pig = pig++;   // assignment overwrites the increment → stays 4-   pig = pig++;+   pig++;         // just increment — no self-assign+   pig++;    System.out.println(pig);   // 6  }}
💡

Bonus: Cards & Questions — Java Basics

TRAP

Constructor vs method — look for the return type

A constructor has NO return type. void Foo() is a method, not a constructor.

RULE

The canonical main signature

public static void main(String[] args) — final is allowed but redundant.

GOTCHA

Local variables have NO default value

Reading a local before a definite assignment is a compile error on every path.

TIP

Initialization order when building an instance

Fields default → initializers & blocks in source order → constructor body.

QUIZ • TIP

Ready to test your grip on Tip?

One OCP-style question that condenses every trick above.

QUESTION • TIP

What is printed when new Builder() is constructed?

  1. SIFC
  2. SFIC
  3. IFSC
  4. SFCI
Explanation Static block runs once (S). Then field initializers and blocks run in source order (F, I). Constructor body last (C).

Your progress, your pace.

Solved and given-up counts are tracked separately — so you can go back and conquer what you skipped.

✓ Solved: 12 ✗ Given up: 3 Total: 20

Replay this tour anytime with the ? button in the header.

1 / 6

Welcome

Your interactive guided tour of the Java Cert study tool.

Skip →