Q86. What is JVM architecture?
The major components include:
Class Loader
Runtime Data Areas
Execution Engine
Garbage Collector
JNI (Java Native Interface)
Q87. What is the difference between Stack and Heap memory?
Stack | Heap |
|---|---|
Stores method frames and local variables/references | Stores objects and arrays |
Each thread has its own stack | Shared across threads |
Automatically managed as methods enter/return | Managed by garbage collection |
Generally faster allocation | Used for dynamic object allocation |
Q88. What is Garbage Collection?
Garbage Collection automatically reclaims heap memory occupied by objects that are no longer reachable.
Q89. Can we force Garbage Collection?
No. We can request it using System.gc(), but JVM is not guaranteed to execute it immediately.
Q90. What is ClassLoader?
A ClassLoader loads Java class files into JVM memory when required.
Q91. What is JIT Compiler?
JIT stands for Just-In-Time compiler. It compiles frequently executed bytecode into native machine code to improve performance.
Q92. What is OutOfMemoryError?
It occurs when the JVM cannot allocate more memory for an object because sufficient memory is unavailable.
Q93. What is StackOverflowError?
It generally occurs when a thread's stack becomes exhausted, commonly due to excessive or infinite recursion.