Java Modern Java

What changed after 8, and what it replaced. Knowing the boundary is what separates experience from having read a recent blog post.

3 concepts · 8 interview questions

What this topic covers

Every concept in modern java, and the questions each one gets asked as. Where a question links, it has a full write-up.

Sealed types and pattern matching

A closed set of subtypes lets the compiler prove a switch is exhaustive, and record patterns remove the cast entirely.

  • What do sealed classes enable that abstract classes cannot?
  • How has pattern matching changed instanceof and switch?
  • What is exhaustiveness, and why does it matter?

The module system

Strong encapsulation of JDK internals — which is why reflection into java.* now needs --add-opens.

  • What did JPMS actually change for application developers?
  • Why does setAccessible fail on a JDK class now?

Versions and migration

LTS releases every two years, with the practical migration pain concentrated in reflection, removed APIs and build tooling.

  • What breaks when you move from Java 8 to 17 or 21?
  • Which Java version should a new project use?
  • What is the difference between LTS and feature releases?

More in Core Java

See the whole reference map →