JVM Internals
Test your understanding of JVM architecture, bytecode, class loading, JIT compilation, runtime data areas, and performance optimisations.
Questions in this quiz
20 questions on JVM Internals. Work through them here, then start the quiz to answer them and see your score.
1.What is the JVM and what is its primary role?
- AA Java code editor bundled with the JDK
- BAn abstract machine that executes Java bytecode, providing platform independence and managing memory
- CA runtime library providing the Java standard library
- DA compiler that converts Java source to native machine code
2.What are the main components of JVM architecture?
- AHeap Manager, Stack Manager, GC, Scheduler
- BCompiler, Linker, Loader, Executor
- CClass Loader, Runtime Data Areas, Execution Engine, Native Interface
- DParser, Interpreter, Optimiser, Runtime
3.What is bytecode?
- APlatform-neutral intermediate instructions generated by javac, stored in .class files and executed by the JVM
- BEncrypted Java source for distribution
- CCompressed Java source code
- DMachine code optimised for x86 processors
4.What are the three phases of class loading?
- AImporting, Resolving, Starting
- BLoading, Linking (Verification + Preparation + Resolution), Initialisation
- CParsing, Compiling, Executing
- DReading, Validating, Running
5.What is the parent delegation model in class loading?
- AChild classloaders always load before parent classloaders
- BThe Bootstrap classloader loads all classes regardless
- CEach classloader loads classes alphabetically by package
- DA classloader delegates to its parent first; only if the parent cannot find the class does the child load it
6.What does this command do?
// Compile: javac Hello.java // Inspect bytecode: javap -c Hello- ACompiles Hello.java and then runs it
- BCompiles Hello.java to Hello.class, then disassembles the bytecode showing JVM instructions
- CCompiles and runs a performance profile
- DCompiles and packages into a JAR
7.What is JIT (Just-In-Time) compilation?
- AA build tool that compiles code only when files change
- BCompiling Java source to bytecode at build time
- CThe JVM compiling frequently executed bytecode (hot spots) to native machine code at runtime for faster execution
- DAhead-of-time compilation for faster startup
8.What is the difference between the JDK, JRE, and JVM?
- AThey are three names for the same thing
- BJDK is for development; JRE is for servers; JVM is for containers
- CJVM is the newest, replacing JRE and JDK
- DJVM executes bytecode; JRE = JVM + standard libraries; JDK = JRE + compiler + tools
9.What is the Program Counter (PC) Register in the JVM?
- AA hardware register used by the JVM for math
- BA register storing the current thread ID
- CA counter tracking the number of objects created
- DA per-thread register that holds the address of the currently executing JVM instruction
10.What is the JVM Stack and what does each stack frame contain?
- AA shared heap area for all method calls
- BA native memory area for C++ method calls
- CA global call queue for scheduling method execution
- DA per-thread LIFO structure where each method call creates a frame holding local variables, operand stack, and frame data
11.What is escape analysis and how does the JVM use it?
- ADetecting threads that escape their thread pool
- BA JIT optimisation that determines if an object's reference escapes the method — if not, the object can be stack-allocated or scalar-replaced
- CA security check preventing objects from leaving their module
- DAnalysis of how many objects escape to the Old Generation
12.What is the invokedynamic bytecode instruction (Java 7+)?
- AAn instruction that defers method dispatch to a bootstrap method at runtime — enables lambdas, dynamic languages, and String concatenation optimisation
- BAn instruction for calling interface default methods
- CAn instruction for calling native methods dynamically
- DA faster alternative to invokevirtual for final methods
13.What is AOT (Ahead-Of-Time) compilation and how does it differ from JIT?
- AAOT compiles to native code before running (at build time) for fast startup; JIT compiles at runtime after identifying hot spots
- BAOT is slower than JIT for all workloads
- CAOT compiles at startup; JIT compiles during deployment
- DThey are the same — AOT is just the term used in GraalVM
14.What is the Constant Pool in a .class file?
- AA pool of pre-allocated objects in the heap
- BA static array of final field values
- CA table in each .class file holding string literals, class names, method references, and field references used by the class
- DA cache of interned strings at runtime
15.What is GraalVM?
- AA high-performance JDK with an advanced JIT compiler, polyglot support, and AOT native image compilation
- BA lightweight JVM for embedded systems
- COracle's cloud-based Java compilation service
- DA monitoring tool for the HotSpot JVM
16.What does the -server JVM flag do?
- AEnables the server's network features
- BIncreases the default heap size to 1 GB
- CActivates the C2 (Server) JIT compiler, which performs deeper optimisations at the cost of longer warm-up time
- DDisables all JIT compilation for stability
17.What is method inlining in JIT compilation?
- AAdding inline comments to compiled methods
- BPre-loading method bytecode before execution
- CReplacing a method call with the body of the called method to eliminate call overhead and enable further optimisations
- DMarking methods as final to prevent overriding
18.What tool would you use to take a thread dump of a running Java process?
- Ajavac --dump-threads
- Bjmap -threads <pid>
- Cjstack <pid>
- Djava -dumpthreads
19.What is the difference between Class.forName() and ClassLoader.loadClass()?
- AClass.forName() loads AND initialises the class (runs static blocks); ClassLoader.loadClass() loads without initialising
- BClass.forName() is faster; ClassLoader.loadClass() is safer
- CClassLoader.loadClass() can load from the network; Class.forName() cannot
- DThey are identical
20.What is tiered compilation in the HotSpot JVM?
- ACompiling only the top-level classes first, then inner classes
- BCompiling in multiple threads for faster build times
- CA strategy using interpreted execution, then C1, then C2 as a method gets hotter — balancing fast startup with peak performance
- DA GC strategy that compiles frequently accessed memory regions