Scrivio Interview library

JVM architecture

27 questions in 7 subtopics.

JVM components

ConceptFoundations6 min read
Describe the main components of the JVM and the runtime data areas it uses.
ConceptFoundations7 min read
Explain class loading in Java 9 and later: the built-in class loaders, delegation, and the phases a class goes through before use.
DebuggingIntermediate7 min read
A long-running service fails with OutOfMemoryError: Metaspace after a few days, and another logs CodeCache is full. Compiler has been disabled. Explain each and how you would investigate.
LeadershipAdvanced7 min read
Your organisation runs Java services on several JDK distributions and versions. How would you choose and standardise JDK distribution and version policy across the fleet?
ConceptPrincipal7 min read
The JVM separates the language from a verified bytecode format that is executed by an interpreter and JIT compilers. Why has this design helped Java last about 30 years, and what does it mean for bets on alternatives such as native images or WebAssembly?

Bytecode and the class file

ConceptFoundations6 min read
What is in a Java class file, and what does UnsupportedClassVersionError: class file version 65.0 mean?
CodingFoundations7 min read
How do string concatenation like "a" + x + "b" and a lambda like list.forEach(s -> print(s)) compile in modern Java? What does javap show?
ConceptIntermediate7 min read
Frameworks like Spring, Hibernate and Mockito generate or modify bytecode at runtime. Explain why and how, and what the Class-File API in Java 24 changes.
ScenarioAdvanced8 min read
Your shared libraries must support services on Java 17, 21 and 25. How do you decide the bytecode baseline, and what options exist to use newer APIs where available?

Interpreter and JIT

ConceptFoundations7 min read
A Java service is slow for its first minutes after each deployment and then becomes fast without any change in load. What happens inside HotSpot during that time, and what does it mean for deployments and benchmarks?
InternalsIntermediate8 min read
Name the JIT optimisations that matter most for Java performance and the code patterns that defeat them.
CodingIntermediate7 min read
A colleague benchmarks two implementations with
long start = System.nanoTime();
for (int i = 0; i < 1000; i++) compute(i);
and reports the time. Why are the results unreliable and how would you benchmark properly?
ScenarioIntermediate8 min read
After each deploy, a service shows high latency for the first few minutes until it warms up. What causes this and what options exist to reduce it in current JDKs?

HotSpot

ConceptIntermediate6 min read
Java 25 made compact object headers a product feature (JEP 519). What are object headers, and what would you check before turning compact headers on for a service?
ConceptIntermediate7 min read
What are the main garbage collectors in HotSpot as of Java 25, and how would you choose among them for a service?
DesignAdvanced7 min read
Teams copy JVM flags from blog posts and old services, so your fleet has hundreds of different flag combinations. How would you standardise JVM configuration?
LeadershipPrincipal6 min read
Over the next five to ten years, should your organisation bet on HotSpot JIT, GraalVM Native Image, or a mix for its Java services? Explain the trade-offs you would weigh.

JVM languages

ConceptFoundations6 min read
Name some JVM languages, explain how they run on the JVM, and what invokedynamic added for them.
ScenarioIntermediate7 min read
A team wants to write new Spring Boot services in Kotlin while the rest of the organisation uses Java. What technical issues should they plan for?
LeadershipAdvanced6 min read
Some teams want to use Kotlin or Scala alongside Java. As the architecture lead, would you allow multiple JVM languages, and under what conditions?
ConceptPrincipal6 min read
Java moved to six-month releases in 2018 and has since added records, pattern matching, sealed classes and virtual threads. How does this change the long-term case for adopting other JVM languages in a large organisation?

Java launcher, classpath and system properties

ConceptFoundations7 min read
Explain how the java launcher finds classes and configuration: the -cp option and its wildcard form, the CLASSPATH variable, -D system properties, JAVA_TOOL_OPTIONS, and @argument files. Which value wins when several are set?
DebuggingIntermediate7 min read
In production a service throws NoSuchMethodError on a Jackson method that exists in the version declared in the build. Locally it works. How do you find which jar the class was loaded from and fix the class path problem?
DesignAdvanced7 min read
Across 200 services, JVM options and system properties are set in Dockerfiles, Helm charts, start scripts and JAVA_TOOL_OPTIONS by different teams, causing incidents. Design how JVM launch configuration should be managed.

JDK command-line tools: jshell, javadoc, jar, jdeps

ConceptFoundations6 min read
Give a practical use for each of these JDK tools in a Java project: jshell, javadoc, jar and jdeps. Show one command for each.
ScenarioIntermediate7 min read
You must upgrade a legacy application from Java 8 to Java 25 and build a small container image. How would you use jdeps and jlink in this work, and what problems do they reveal?
LeadershipPrincipal6 min read
The JDK has shipped tools like javadoc and jar since Java 1.0 and added jshell, jlink and jdeps much later, while most teams use build tools and IDEs instead. As the senior technical leader, how much should your engineering organisation invest in JDK tool skills and standard tooling?