Internal Details of Java Program With Example


Internal Details of Java

Internal Details of Java

we are going to learn, what happens while compiling and running  the internal details of  Java program.

Compile Time V/S  Run Time : The source code must be compiled into machine code in order to become an executable program. This compilation process is referred to as compile-time. A compiled program can be opened and run by a user. When an application is running, it is called runtime.



what happens when you compile a program ?

While compiling , Java file is compiled by Java Compiler and converts the Java code into byte code.


what happens when you Run/Execute  a program ?

At runtime, following steps are performed:


Class loader: is the subsystem of JVM that is used to load class files.

Byte code Verifier : checks the code fragments for illegal code that can violate access right to objects.

Interpreter : read byte code stream then execute the instructions.

What’s So Good About JAVA ?

What makes this language different from many others?

1. Probability : This term means that you can write a program for one type of computer, but run it on many different platforms. Most likely you’ve had a chance to see it cause some Internet pages besides HTML, contain so called applets, which are Java programs that work under control of your browser.

2. Built-in Security : What are the chances that some bad guy will decide to write an applet in Java that will delete soem files from your hard disk ? No, Way because Java applet can not access the hard disk of user computers unless special files were created.

3. Error Processing : It is mandatory in Java to handle possible run-time errors.Java has a mechanism called “Exception” and of you are calling a method that may give a run-time error,you will not be able to compile this program until you have taken care of these possible errors .This feature lowers the number potential bugs in Java programs,while in other languages, programmers have to decide what kind of errors should be processed.

4. Internationalization : Internationalization is the ability to translate you programs to other sells books in Germany and Sun Microsystems sells their products in Russia. It’s not difficult to translate an English site to a Russian one because have alphabets consisting of a limited number of letters.

5. Multi threading : Multi threading allows one running program to start multiple executing lightweight processes, which run in parallel. This can speed up the performance of your programs tremendously,especially if the computer is equipped with multiple processors.

6. Java is easier to learn than C++ : While Java is a very and powerful OOP language based on C++. some of the most complex elements of the C++ language have been removed from Java.

Getting Started : The Java Development Kit (JDK) could be download from the Sun Microsystems Internet site.

The Installation process is pretty simple-just run the download executable file and it’ll install it on your disk. To start writing Java program you could use any plain text editor. In windows,it could be an editor called Notepad.In Linux it could be Gedit or Nano editor.The files with Java programs must be saved in a plain text format and must have names ending in .java . For example, if you want to write a program called MyFirstProgram ,enter its code in Notepad and save it in a class named Keep in mind that Java is a case sensitive language, which means that if you named the program with a capital letter, do not try to start the program with small letter.

To compile: javac . [ javac (space) ]

To execute/Run: java Simple. Java space filename

Let’s review the steps you would perform to create and run the program :

Step 1. Set the values for the PATH and CLASS PATH system variables.

Step 2. Create a new directory called practice.

Step 3. Using text editor, enter the code of the class , MyFirstProgram and save in the file c:\practice\

Step 4. Compile and Run the program : c:\practice>java , c:\practice>java MyFirstProgram.

Data Types : Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory.

Two types of data types in Java :


1. Primitive Data Types –There are eight primitive data types supported by Java. Primitive data types are predefined by the language and named by a keyword.

byte: byte data type is an 8-bit signed two’s complement integer.

Values From -128 (-2^7) 127(2^7-1)

Short : Short data type is a 16-bit signed two’s complement integer. From -32,768 (-2^15)32,767(2^15 -1)

int : 32-bit signed from (-2^31)(2^31 -1)

char : 32-bit signed from (-2^31)(2^31 -1)

boolean: 64-bit signed from (-2^63) (2^63 -1)

double: 32-bit0, Default value is Zero (0f) float f1 = 234.5f

float: 64-bit ,Default value is 0.0d.double d1 = 123.4

long: two possible values, true and false. one=true zero=false

int: 16-bit Unicode character

2. Reference Data Types : Reference variables are created using defined constructors of the classes. They are used to access objects. These variables are declared to be of a specific type that cannot be changed. For example, Employee, Puppy etc.

Default value of any reference variable is null. A reference variable can be used to refer to any object of the declared type or any compatible type.

Java Literals :

A literal is a source code representation of a fixed value. They are represented directly in the code without any computation.

Literals can be assigned to any primitive type variable. For example:

byte a = 68;
char a = 'A'



  1. Praveen June 14, 2016