0% found this document useful (0 votes)
10 views

Class 5

Uploaded by

M
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Class 5

Uploaded by

M
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Internal Architecture of JVM

============================
Diagram: class5.1

Java program contains java code instructions.Once if we compile java code


instructions converts to byte code instructions in .class file.

Now JVM will invoke one module called classloader or sub system to load all the
byte code instructions from .class file.The work of classloader is to check these
byte code instructions are proper or not.
If they are not proper then it will refuse the execution. If they are proper then
it will allocates the memories.

We have five types of memories.

1) Method Area
------------
It contains code of a class, code of a variable and code of a method.

2) Heap
--------
Our object creations will store in heap area.

3) Java Stack
--------------
Java methods will store in method area.
To execute those methods we required some memory and that memory will be allocated
in java stack.

4) PC Register
--------------
It is a program counter register which is used to track the address of an
instructions.

5) Native Method Stack


-----------------------
Java methods will execute in method area.
Similarly native methods will execute in native method stack.
But to execute native methods we required a program called Native method interface.

Execution Engine
----------------
Execution engine contains interpreter and JIT compiler.

Whenever JVM loads byte code instructions from .class file , it will uses
interpreter and JIT compiler.

Interpreter is used to execute our program line by line procedure.

JIT compiler is used to increase the execution speed of our program.

Finally , JVM converts byte code to machine code.


Interview Question
===================

Q) What is native method in java?

A method which is developed by using some other language is called native method.

Q) How many memories are there in java?

We have five memories in java.

1) Method Area

2) Heap

3) Java Stack

4) PC Register

5) Native Method Stack

Q) What is JIT compiler?

It is a part of a JVM which is used to increase the execution speed of our program.

Q) How many classloaders are there in java?

We have three classloaders in java.

1) Bootstrap classloader

2) Extension classloader

3) Application/System classloader

Identifiers
===========
A name in java is called identifier.

It can be variable name, method name, class name or label name.

ex:
class Test
{
public static void main(String[] args)
{
int x = 10;

System.out.println(x);
}
}

Here Test, main ,String , args, x , System are identifiers.


Rules to declare an identifiers
--------------------------------
Rule1:
------
Identifier will accept following characters.
ex:
A-Z
a-z
0-9
_
$

Rule2:
------
If we take other characters then we will get compile time error.
ex:
int emp$al;
String stud_Name;
double emp#Fee; //invalid

Rule3:
------
Identifier must and should starts with alphabet, underscore or dollar symbol
but not
with digits.
ex:
int _empId; //valid
int $alary;//valid
int a1234; //valid
int 1abcd; //invalid

Rule4:
------
Every identifier is a case sensitive.
ex:
int number;
int NUMBER;
int NuMbEr;

Rule5:
-----
We can't take reserved words as an identifier name.
ex:
int if; //invalid
int else; //invalid

Rule6:
-----
There is no length limit for an identifier but it is not recommanded to take
more then
15 characters.

You might also like