Popular Posts

Wednesday, March 26, 2014

Core Java Basics.

hi friends ,
This as it is an information an eduaction related blogs, so i thought that i should start java tutorial
which may helpful to students.
So as it is the first session of this tutorial we discuss about core java basics. Here you will not find a complete java tutorial package but still you can get some useful facts about core java.This tutorial is for interview perspective.
lets starts..........


                                                         Core Java Basics

Q). What is JVM?
Ans: -   Java Virtual Machine (JVM) is a collection of program  that provide the complete environment in the system which  is required to execute the java application. This collection of program make the processor to execute the java application.
Q).     Why do  we need  JVM?
Ans:-     We need JVM to provide the environment to execute java application or  make processor to execute java application  or byte code we need JVM. Whatever the OS is doing in case of ‘C’ application all this provided by the JVM due to which workload of the OS decreases.  Something like JVM  is not available in the  ’C’  application since Operating System (OS)  takes care of the execution of C application. . Operating system would not involve and provide any kind of services in executing java application
Q). Responsibility of the JVM
Ans:- Apart from converting the byte code into its equivalent executable code ,JVM has many  other responsibility or we can say many work has been done  automatically . Since machine is something related to the physical entity , so in order to represent that it is not physically present  (imaginary) since the program is under execution  we termed it as a Virtual Machine. And this machine related to java technology so we called it as Java Virtual Machine (JVM ) .


Without using library function you cannot imagine to develop any program. Using library function is more  when we are developing the java application. When u compile then we get same no of function whatever u  mention in your source code of  java program ,so here the question arises that how we can use the library function which is not present in the byte code of the .class file which is present in the source file. Any middle language (byte code)  is highly optimized .We are asking jvm(Actually processor  )   to execute the byte code , jvm would not convert all the 100 functions byte code into its equivalent  executable code(Executable code is highly dynamic in java it will generate only when the function call is made) ,only the executable code of the main method is loaded to the RAM. JVM first searches and locate  the main method out of 100 method (previously it is done by OS) ,then it will allocate the memory in the RAM for only main method and ask processor to start the execution of the program which is present in such address  of the RAM accordingly the processor come to the particular place and loads the main method. All the addresses  maintains by the jvm (previously by OS).
Processor can execute any function which is present inside the RAM in the form of its executable code. When function call is made then the processor searches  it in the RAM  if this function is not found in the RAM the JVM searches it into the byte code  once its find that function in the byte code then it allocate the memory space in the RAM and loads the functionality and when the functionalities is completes then it is automatically garbage collected.
Once the execution of the function is completes then executable code from  the RAM is deleted and the control returns to the calling place , that’s why we cannot see  executable code of java due to highly dynamic.
 
Who loads jvm to RAM who makes the processor to start the jvm .
Ans: -OS
 A part of the RAM would be exclusively allocated for the JVM  for executing functionalities  is known as workarea  which is assigned by OS to JVM.
JVM divides into several area :
1).  Stack : local variable
2).  Heap: Objects
3). Partitions for the byte code (Allocating the memory space for byte code is not considered since it is not understandable by the processor)
àByte code loaded into the RAM only for the sake of RAM.
So for the processor byte code present in the RAM or byte code present in the HARD DISC is same  , since processor does not understand byte code.
Whenever function call  is  made complete  byte code is loaded into the RAM
Cache memory : small piece of the RAM for maintaining functionalities temporarily which is executed .when we made function call second time then control first searches in the cache memory if find that executable code of the function and loads into the work area , if not find then control again goes to the byte code and do the same procedure again. Once the control outs from the main method then it is going to delete all the executable code which is present in the cache and also it deletes the corresponding byte code from the workarea. In order to maintain byte code in workarea some program is available.



 
 

No comments:

Post a Comment