Java Interview Question Series Part 1

Curio Code
2 min readOct 9, 2022

--

  1. What is the difference between JDK and JRE?

JDK stands for Java Development Kit. It contains the tools and libraries for the development of Java programs. It also contains compilers and debuggers needed to compile Java programs.

JRE stands for Java Runtime Environment. This is included in JDK. JRE provides libraries and JVM. that are required to run a Java program.

2. What is Java Virtual Machine(JVM)?

Java Virtual Machine is an abstract machine that executes Java Bytecode. There are different hardware and software platforms. So JVM is platform-dependent. JVM is responsible for loading verifying and executing the bytecode on a platform.

3. What are the different types of memory areas allocated by JVM?

In Java, JVM allocated memory to different processes, methods and objects. Some of the memory areas allocated by JVM are:

1. ClassLoader: It is a component of JVM used to load class files.

2. Class(Method) Area: It stores per-class structure such as the runtime constants pool, field and method data, and the code for methods.

3. Heap: Heap has created a runtime and it contains the runtime data area in which objects are allocated.

4. Stack: Stack stores local variables and partial results are runtimes. It also helps in method invocation and return value. Each thread creates a private JVM stack at the time of thread creation.

5. Program Counter Register: This memory area contains the address of the Java Virtual Machine instruction that is currently being executed.

6. Native Method Stack: This area is reserved for all the native methods used in the application.

4. What is a JIT compiler?

Just in time compiler also known as the JIT compiler is used for performance improvement in Java. It is enabled by default. It is a compilation done at execution time rather than earlier

Java has popularized the use of the JIT compiler by including it in JVM

5. How Java platform is different from other platforms?

Java is a platform-independent language.Java compiler that converts Java code into byte code that can be interpreted by JVM. There are JVM written for almost all the popular platforms in the world.

Java byte code can run on any supported platform in the same way. Where as other languages require libraries compiled for a specific platform to run.

--

--