Computer Science, asked by MrTSR, 3 months ago

✪ Computer Science Question ✪

What is \bold{Java\:Virtual\:Machine} (JVM)?

Explain with points

Answers

Answered by Oreki
8

\textsf{\large\bf The Java Virtual Machine (JVM)}

  \textsf{Java Virtual Machine (JVM) is the heart of entire Java program execution process.}\\\textsf{It is responsible for taking the class file and converting each byte c\symbol{111}de instruction}\\\textsf{into the machine language instruction that can be executed by the microprocessor.}

 

\text{\large\bf Working}

    \textsf{First of all, the .java program is converted into a .class file consisting of }\\\textsf{byte c\symbol{111}de instructions by the Java compiler. Remember, this Java compiler}\\\textsf{is outside the JVM. Now this .class file is given to the JVM. In JVM, there}\\\textsf{is a module (or program) called \textit{class loader sub system,} which}\\\textsf{performs the following functions:}

       \textsf{\textemdash \: First of all, it loads the .class file into memory.}\\\textsf{\textemdash \: Then it verifies whether all byte c\symbol{111}de instructions are proper or not.}\\\textsf{\: \: \:\:If it finds any instruction suspicious, the execution is rejected immediately.}\\\textsf{\textemdash \: If the byte instructions are proper, then it allocates necessary memory to}\\\textsf{\: \: \:\:execute the program.}

    \textsf{This memory is divided into 5 parts, called run time data areas, which contain}\\\textsf{the data and results while running the program.}\\\textsf{These areas are as follows: }

         \textsf{\textemdash \: \textbf{Method area}}\\\textsf{\: \: \: It is the memory block, which stores the class c\symbol{111}de, c\symbol{111}de of the variables,}\\\textsf{\: \: \: and c\symbol{111}de of the methods in the Java program.}\\

         \textsf{\textemdash \: \textbf{Heap}}\\\textsf{\: \: \: This is the area where objects are created. Whenever JVM loads a class,}\\\textsf{\: \: \: a method and a heap area are immediately created in it.}\\

         \textsf{\textemdash \: \textbf{Java Stacks}}\\\textsf{\: \: \: Method c\symbol{111}de is stored on Method area. But while running a method,}\\\textsf{\: \: \: It needs some more memory to store the data and results.}\\\textsf{\: \: \: This memory is allotted on Java stacks. So, Java stacks are memory areas}\\\textsf{\: \: \: where Java methods are executed.}

         \textsf{\textemdash \: \textbf{PC (Program Counter) registers}}\\\textsf{\: \: \: These are the registers (memory areas), which contain memory address of }\\\textsf{\: \: \: the instructions of the methods. }

         \textsf{\textemdash \: \textbf{Native method stacks}}\\\textsf{\: \: \: Java methods are executed on Java stacks. Similarly, native methods }\\\textsf{\: \: \: (for example C/C++ functions) are executed on Native method stacks. }

   \textsf{Execution engine contains interpreter and JIT (Just In Time) compiler, which are}\\\textsf{responsible for converting the byte c\symbol{111}de instructions into machine c\symbol{111}de so that the}\\\textsf{processor will execute them.}

Answered by itzYourKamina
3

refer to the attachment

Attachments:
Similar questions