Question
Explain the working of JVM.
Answer
-
When we execute the java file, JVM is loaded into the main memory.
-
In JVM, first class loader starts which loads the class into memory ie. it divides the code into Runtime Memory Area.
-
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.
- After the class loader, execution engine ( which consists of the JIT compiler) , runs which translates byte code into object code and library is loaded.