Your interactive OCP 21 prep — challenges, quizzes, and a stopwatch for your brain.
A 45-second tour of everything you can do. Let me show you.
Complete the program so it prints 42.
public class Demo { public static void main(String[] args) { var answer = 6 * 7; System.out.println(answer); } }
42
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 :( } }
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 }}
A constructor has NO return type. void Foo() is a method, not a constructor.
public static void main(String[] args) — final is allowed but redundant.
Reading a local before a definite assignment is a compile error on every path.
Fields default → initializers & blocks in source order → constructor body.
One OCP-style question that condenses every trick above.
What is printed when new Builder() is constructed?
Solved and given-up counts are tracked separately — so you can go back and conquer what you skipped.
Replay this tour anytime with the ? button in the header.
Your interactive guided tour of the Java Cert study tool.