What is the difference between JDK and JRE?
JDK (Java Development Kit) is for developing Java programs and includes tools like the compiler (javac), debugger, and libraries. JRE (Java Runtime Environment) is for running Java programs and includes the JVM and standard libraries. JDK contains JRE.
What does JDK include?
JDK includes JRE + development tools such as compiler (javac), debugger, documentation tools, and utilities needed to build Java applications.
What does JRE include?
JRE includes JVM + core class libraries + runtime files required to execute Java programs.
Can you run Java code with only JRE installed?
Yes, you can run compiled Java programs, but you cannot compile new Java code because the compiler is part of JDK, not JRE.
Can you compile Java code with only JRE installed?
No. Compilation requires javac, which exists only in JDK.
What is the role of JVM inside JRE?
JVM executes Java bytecode, manages memory, performs garbage collection, and ensures platform independence.
JDK vs JRE vs JVM in one sentence?
JDK develops programs, JRE runs programs, JVM executes bytecode.
Why is Java called platform independent?
Because Java code compiles into bytecode that runs on any JVM regardless of operating system.
Which component actually executes Java bytecode?
The JVM executes bytecode instructions.
What happens if JVM is missing from a system?
Java programs cannot run because the execution engine is absent.
What is the Java Virtual Machine (JVM)?
The JVM (Java Virtual Machine) is a runtime engine that executes Java bytecode and provides platform-independent execution by translating bytecode into machine-specific instructions.
Is JVM platform dependent or platform independent?
JVM implementation is platform dependent (different JVM for each OS), but Java programs are platform independent because the same bytecode runs on any JVM.
What are the main responsibilities of JVM?
JVM loads class files, verifies bytecode, executes code, manages memory, and performs garbage collection.
What does JVM actually execute?
JVM executes compiled Java bytecode, not source code.
What is bytecode in Java?
Bytecode is the intermediate compiled form of Java source code generated by javac that runs on the JVM.
Why does Java achieve ‘Write Once, Run Anywhere’?
Because Java code compiles into bytecode that runs on any JVM regardless of underlying hardware or operating system.
What happens during class loading in JVM?
JVM loads .class files into memory, verifies their correctness, links them, and initializes static data before execution.
What is bytecode verification in JVM?
It is a security step where JVM checks code for illegal instructions, invalid memory access, and type safety violations before execution.
Does JVM manage memory automatically?
Yes. JVM automatically manages memory allocation and garbage collection for objects on the heap.
What is the difference between JVM and JRE?
JVM executes bytecode, while JRE includes JVM plus libraries required to run Java applications.
What are the main memory areas of the JVM?
The main JVM memory areas are Heap, Stack, Method Area, Program Counter Register, and Native Method Stack.
What is the Heap in JVM?
Heap is the runtime memory area where objects and instance variables are allocated. It is shared across all threads and managed by garbage collection.
What is the Stack in JVM?
Stack stores method frames including local variables, parameters, and partial results. Each thread has its own private stack.