WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Core Java · Basic · question 3 of 100

What is the difference between JDK, JRE, and JVM?

📕 Buy this interview preparation book: 100 Core Java questions & answers — PDF + EPUB for $5

JDK, JRE, and JVM are three important components of the Java platform. Here’s what each one is and how they differ from each other:

JDK (Java Development Kit): The JDK is a software development kit that includes the tools necessary for developing Java applications. It includes the Java compiler, which compiles Java source code into bytecode, and the Java runtime environment, which allows compiled Java code to run on a machine.

JRE (Java Runtime Environment): The JRE is a runtime environment that allows compiled Java code to run on a machine. It includes the Java Virtual Machine (JVM), which is responsible for interpreting and executing the bytecode generated by the Java compiler.

JVM (Java Virtual Machine): The JVM is a virtual machine that provides an environment in which Java code can run. It interprets the bytecode generated by the Java compiler and executes it on a machine.

In short, the JDK is used for developing Java applications, the JRE is used for running Java applications, and the JVM is used for executing Java bytecode.

Here’s an example Java program that demonstrates the use of these components:

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

To compile and run this program, we would need the JDK installed on our machine. We would use the javac command, which is part of the JDK, to compile the Java source code into bytecode:

javac HelloWorld.java

This command would generate a file called HelloWorld.class, which contains the bytecode for our program. To run the program, we would need the JRE installed on our machine. We would use the java command, which is part of the JRE, to execute the bytecode:

java HelloWorld

This command would run the HelloWorld class, which contains the main method that prints "Hello, world!" to the console. The JVM, which is part of the JRE, would interpret and execute the bytecode generated by the Java compiler.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Core Java interview — then scores it.
📞 Practice Core Java — free 15 min
📕 Buy this interview preparation book: 100 Core Java questions & answers — PDF + EPUB for $5

All 100 Core Java questions · All topics