Skip to content

A little — every day.

Java OCA 8 through a frontend developer's eyes

11 min read

On this page
In short
I’m a frontend developer working with Angular and TypeScript, and I’m preparing for the Oracle Java SE 8 Programmer I certification (1Z0-808) with the book by Boyarsky and Selikoff. The goal is a junior or intern interview for Java (Spring) backend. In this post: progress in numbers, what each of the six chapters covers, where TypeScript habits lead to a wrong answer, and one or two LeetCode problems per chapter to reinforce it with code. Java and TypeScript syntax look alike, so the trickiest places are the ones where the code looks familiar but works differently.

Why Java and why this exam

The goal is to be able to write backend in Java/Spring, not only frontend. A certificate by itself doesn’t get you a job. But preparing for it forces you to learn the core of the language down to the details, not “at Stack Overflow level”. The exam tests exactly the details: will this code compile, what will it print, which exception will it throw.

The book is the official Study Guide for this exam: 6 chapters, each with a list of exam objectives, a summary and review questions. At the start there’s an assessment test; at the end, answers with explanations and tips for preparing.

The plan in numbers

Each chapter’s pages are counted from the table of contents: the start of the next chapter minus the start of the current one.

ChapterTopicPagesDays at 10 pages/day
1Java Building Blocks1–50 → 505
2Operators and Statements51–100 → 505
3Core Java APIs101–164 → 647
4Methods and Encapsulation165–232 → 687
5Class Design233–298 → 667
6Exceptions299–332 → 344
Total33235

Why 35 and not 332 / 10 = 33.2? Because the days are counted per chapter and rounded up: 64 pages is 7 days, not 6.4 — a partial day still takes a day. The sum of the rounded values: 5 + 5 + 7 + 7 + 7 + 4 = 35. This is rounding up (ceil) — the same as Math.ceil(64 / 10) in programming.

Where I am now

I’ve read 271 pages out of 332 — the middle of chapter 5, the section on interfaces.

  • Read: 271 / 332 = 0.816 → 82%.
  • Left: 332 − 271 = 61 pages.
  • At 10 pages a day: ⌈61 / 10⌉ = ⌈6.1⌉ = 7 days → the chapters will be done by 16 November.

The ⌈ ⌉ brackets are the same rounding up: 6.1 days is still seven calendar days.

After that — not “read it and forgot it”, but revising chapters 1–4 through LeetCode problems (plan below) and practice tests. The target is December, when I start applying for jobs.

The self-check rule: after each chapter, the Review Questions without hints, the result as a percentage. Below 65% (the exam’s pass mark), the chapter is reread, not “I’ll sort it out later”.

Chapter 1. Java Building Blocks

What it covers: class structure, main(), packages and imports, constructors and initialisation order, primitives and reference types, variable scope, the garbage collector.

Where TypeScript gets in the way:

  • There are eight primitives, and they have a fixed size. TypeScript has one number for everything. Java has byte (8 bits), short (16), int (32), long (64), float, double, plus char and boolean. The size decides whether a value fits: byte holds −128 to 127, because 8 bits give 2⁸ = 256 values, and half of them go to negative numbers.
  • A local variable without a value can’t be read. In TypeScript it’s undefined. In Java it’s a compile error. Class fields, on the other hand, get a default value: 0, false, null.
  • A wildcard import doesn’t reach into subpackages. import java.util.*; doesn’t import classes from java.util.concurrent.

Exam trap: the order in which an object is initialised. First the fields and initialiser blocks — top to bottom, in the order they’re written — and only then the constructor body.

public class Order {
    private String name = "поле";
    { System.out.println(name); }          // блок инициализации
    public Order() { name = "конструктор"; System.out.println(name); }
    public static void main(String[] args) { new Order(); }
}
// напечатает: поле, затем конструктор

My Review Questions result: TODO

Chapter 2. Operators and Statements

What it covers: operators and their precedence, type promotion in calculations, if, switch, loops, break and continue with labels.

Where TypeScript gets in the way:

  • Numbers are “promoted” in calculations. Arithmetic on byte and short always gives int. So byte a = 1, b = 2; byte c = a + b; won’t compile: the right side is int, and it can’t be silently put into a byte.
  • Integer division. In Java 7 / 2 is 3, not 3.5, if both numbers are integers. In JavaScript it’s 3.5.
  • if only accepts a boolean. No “truthiness”: if (count) with a number won’t compile. The JS habit of writing if (value) is an error here.
  • In Java 8, switch works with int and smaller types, char, String and enum, but not with long or boolean.

Exam trap: x++ and ++x in the same expression. The postfix form returns the old value, the prefix form the new one:

int x = 3;
int y = x++ + ++x;   // 3 + 5 = 8, а x в итоге 5

My Review Questions result: TODO

Chapter 3. Core Java APIs

What it covers: String and the string pool, StringBuilder, comparing with == and equals(), arrays, ArrayList, wrappers and autoboxing, dates and times from java.time.

Where TypeScript gets in the way:

  • On objects, == compares references, not contents. Two different strings with the same text may not be equal by ==. Contents are compared by equals(). In JS, === on strings compares values, so your hand writes == — and the answer is wrong.
  • Strings are immutable, as in JS: s.toUpperCase() returns a new string and doesn’t change s. If you don’t assign the result, it’s lost. The exam loves code like that.
  • An array has a fixed length. Arrays have no push; for a growing list there’s ArrayList.
  • substring(begin, end) doesn’t include end — like slice in JS. On the other hand, StringBuilder’s methods append, insert, delete change the object itself, while substring doesn’t.
  • Dates are immutable. date.plusDays(1) returns a new date. A call without assignment does nothing.

Exam trap: ArrayList<Integer> has two remove methods: by index (int) and by object (Integer):

List<Integer> list = new ArrayList<>(Arrays.asList(10, 20, 30));
list.remove(1);                    // удалит элемент с индексом 1 → [10, 30]
list.remove(Integer.valueOf(10));  // удалит значение 10 → [30]

My Review Questions result: TODO

Chapter 4. Methods and Encapsulation

What it covers: declaring methods, access modifiers, static, passing parameters, overloading, constructors, encapsulation, immutable classes, simple lambdas and Predicate.

Where TypeScript gets in the way:

  • Four access levels, not three. private, no modifier (“package-private” — visible inside the package), protected (package + subclasses), public. TypeScript has no “inside the package” level.
  • Java always passes by value. For objects, the reference is passed by value. Assign a new object to the parameter, and the caller won’t see it. Call a method on the object, and it will. It’s the same as in JS, but the exam checks it at every step.
  • Method overloading. In TypeScript, overloads are only types; the function has one body. In Java, several methods with the same name really are different methods, and the compiler picks the right one.

Exam trap: the order in which an overload is chosen. First an exact type match, then widening a primitive (int → long), then autoboxing (int → Integer), and only then varargs:

static void print(long x)    { System.out.println("long"); }
static void print(Integer x) { System.out.println("Integer"); }
public static void main(String[] args) { print(5); }   // long: расширение раньше упаковки

My Review Questions result: TODO

Chapter 5. Class Design

What it covers: inheritance, calling parent constructors, overriding and hiding methods, abstract classes, interfaces with default and static methods, polymorphism and casting.

Where TypeScript gets in the way:

  • Typing is nominal, not structural. In TypeScript an object fits an interface if it has the required fields. In Java a class fits only if it explicitly says implements.
  • The first line of a constructor is always this(...) or super(...). If you don’t write it, the compiler inserts super(). And if the parent has no constructor without parameters, the code won’t compile.
  • Overriding and hiding. An ordinary method is overridden: the version of the actual object is called. A static method is hidden: the version for the variable’s type is called. Fields are hidden too, not overridden.

Exam trap: the rules for overriding. The method in the subclass must have the same signature, be no less accessible, declare no new or broader checked exceptions, and return the same type or a subtype.

My Review Questions result: TODO

Chapter 6. Exceptions

What it covers: what exceptions are for, checked and unchecked, try/catch/finally, common exceptions, throw and throws.

Where TypeScript gets in the way:

  • Checked exceptions. In TypeScript any function can throw anything, and the compiler says nothing. In Java a checked exception (a subclass of Exception, but not of RuntimeException) must be either caught or declared in throws. Otherwise the code won’t compile.
  • The order of catch matters. A block for a parent exception above the block for a child one is a compile error: the second block is unreachable.
  • finally runs almost always, even if try contains a return.

Exam trap: throw and throws. throw new X() throws an exception inside a method; throws X in a method declaration warns that it may be thrown.

My Review Questions result: TODO

LeetCode for each chapter

The book teaches the language, but a junior or intern interview almost always includes a “write some code” task. So each chapter gets one or two problems where its topic is really needed. Not for the count: I write up each problem in leetcode/ from a template and set a confidence and a review date.

Legend: ✅ solved, ⬜ planned. The problems are chosen so that the chapter’s trap shows up in code, not only in a test.

ChapterProblemDifficultyWhat it reinforces
1. Building Blocks⬜ 7. Reverse Integermediumint is 32 bits: overflow, checking against Integer.MAX_VALUE before multiplying
1. Building Blocks⬜ 9. Palindrome Numbereasyinteger division / 10 and remainder % 10 instead of converting to a string
2. Operators⬜ 136. Single NumbereasyXOR (^): a ^ a = 0, a ^ 0 = a — a solution with O(1) memory
2. Operators⬜ 191. Number of 1 Bitseasyshifts: the difference between >> and >>> for negative numbers (JS has the same pair)
3. Core APIs✅ 151. Reverse Words in a StringmediumString is immutable, split, StringBuilder
3. Core APIs⬜ 242. Valid Anagrameasyan int[26] array and char arithmetic: c - 'a' is a number
3. Core APIs⬜ 1. Two SumeasyHashMap: one of the most common interview problems
4. Methods✅ 206. Reverse Linked Listeasyreferences are passed by value: what changes for the caller and what doesn’t
4. Methods✅ 21. Merge Two Sorted Listseasythe same: working with references in a loop; for revision, rewrite it recursively
4. Methods⬜ 49. Group Anagramsmediuma lambda in computeIfAbsent(key, k -> new ArrayList<>())
5. Class Design✅ 20. Valid ParentheseseasyDeque (an interface) instead of Stack (a class); autoboxing of Character
5. Class Design⬜ 155. Min Stackmediumyour own class: private fields, encapsulation, only the public methods needed
5. Class Design⬜ 232. Implement Queue using Stackseasyimplementing a given API on top of another structure
6. Exceptions⬜ 8. String to Integer (atoi)mediumwhat Integer.parseInt does and when it throws NumberFormatException; handling edge cases by hand

Total: 4 solved, 10 planned.

Tricky spots worth checking in the problems

  • Integer and ==. Comparing two Integer objects with == works for numbers from −128 to 127 (they’re cached) and breaks for larger ones. In problem 20 I use equals — correct. It’s a common interview question.
  • A char is a number. 'b' - 'a' == 1, so int[26] instead of HashMap for letters.
  • Overflow is silent. Integer.MAX_VALUE + 1 gives a negative number without an error. In problems 7 and 8 that’s the whole point.

Pace

10 problems in 4 weeks: 2–3 problems a week after reading, and at weekends, revising the problems whose next_review date has come.

WeekProblems
10–16 Novemberfinish chapters 5–6; 155, 232
17–23 November7, 9, 136
24–30 November191, 242, 1
1–7 December49, 8 + revise 20, 21, 151, 206

After the book: what else a Spring backend needs

The OCA book is about Java Core. A backend developer interview will also ask about:

  • SQL — LeetCode has the SQL 50 set; start with 175 (Combine Two Tables) and 176 (Second Highest Salary): JOIN, LIMIT/OFFSET, NULL.
  • Collections in more depth: HashMap internals, equals/hashCode.
  • Spring Boot: a pet project with a REST API and a database — it matters more than the number of problems solved.

How I study

  • 10 pages a day, progress in the book card; problems in leetcode/.
  • I type out every example from the book by hand and run it (javac + java) rather than just reading it. The exam tests what code does, and you only see that by running it.
  • Before running it I write down my answer: “will it compile? what will it print?”. Then I compare. If I was wrong, I write down why.
  • Review Questions without hints, the result goes into the table.

What’s next

After the book: practice tests and booking the exam. Then Spring Boot and a pet project: a certificate tests the language, but you get hired for what you can build with it.