Styrow.dev
Question 8 of 247
Java Topic: General medium

Explain the working of JVM.

Question

Explain the working of JVM.

Answer

  1. When we execute the java file, JVM is loaded into the main memory.

  2. In JVM, first class loader starts which loads the class into memory ie. it divides the code into Runtime Memory Area.

  3. Runtime Memory Area consists of :-

a.) Heap-All the objects in the program are stored in heap.

b.) Stack-All local and reference variables are stored in stack.

c.) Method Area-It is permanent area.It consists of static variables , function and class definitions.

d.) Native Code Area-The code which is not a part of java but is the part of the platform ie. OS , that code is called the native code.

e.) Program Counter Register-holds the address of the next instruction which is going to execute.

  1. After the class loader, execution engine ( which consists of the JIT compiler) , runs which translates byte code into object code and library is loaded.