Introduction to Java

Introduction to Java:

Java is a high level Object Oriented Programming Language created by James Gosling et al. of Sun Microsystems. Java originally created in 1991.The first version of java which is available to the public in 1995. Java introduced with the great features of Java Virtual Machine (JVM), Garbage Collection and Code Security with a built-in application programming interface (API). Java originally named as Oak, but there is already a language exists with that name and also with some patent issues it renamed as Java.

Characteristics of Java :
  • Java is open source, its free to use
  • Java is simple (for development)
  • Java is object-oriented
  • Java is distributed
  • Java is interpreted
  • Java is robust
  • Java is secure
  • Java is architecture-neutral
  • Java is portable
  • Java’s performance
  • Java is multithreaded
  • Java is dynamic
  • Java is Platform-independent.

One of the important characteristics of java which we need to talk about is Platform-independent. It represents “Write once run anywhere”. It means that we can write the java program in any of the Operating System and run in any Operating System. Java supports all kinds of Operating Systems like Solaris, Linux, Windows, and AIX etc. Earlier Java is developed for small computing devices, now Java is a powerful tool for developing scalable and robust enterprise applications.


Java Development Kit, It’s a bundle of Software used to develop Java based applications. This needs for the Java programmer or developer to develop Java Programs. It should be installed before developing the programs in java. The current version of JDK using in the market is 1.6, which is available freely in the following link

Java Development Kit contains tools needed to develop the Java programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, Javadoc etc…

Compiler :

Compiler used to convert the java code into Byte code. The source file of java program should be ended with “.java” extension. After the compilation .class file generated it contains the byte code, which can be understand the JVM to run.


Java Virtual Machine used to run the Java Program. The Java Virtual Machine provides a platform-independent way of executing code; programmers can concentrate on writing software, without having to be concerned with how or where it will run. JVM runs the programs using the class libraries provided by the Java Run-time Environment (JRE). When we compile a Java file, It generates a ‘.class’ file. ‘.class’ file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent. The JVM is called “virtual” because it provides a machine interface that does not depend on the underlying operating system and machine hardware architecture. This independence from hardware and operating system is a cornerstone of the write-once run-anywhere value of Java programs.

There are different JVM implementations are there. These may differ in things like performance, reliability, speed, etc. These implementations will differ in those areas where Java specification doesn’t mention how to implement the features, like how the garbage collection process works is JVM dependent, Java spec doesn’t define any specific way to do this.


Java Run-time Environment, It provides class libraries for running the Java Programs. JRE needs to be installed to run the Java applications. JRE is targeted for execution of Java files.
i.e. JRE = JVM + Java Packages Classes (like util, math, lang, awt, swing etc) + runtime libraries.

Heap :

Heap is a memory (Part of RAM) holds by JVM. Normally the objects created in the Java application are stored in the Heap. It is a temporary memory which is available only at the time of running the JVM.

Stack :

Stack is memory (Part of RAM) holds by JVM. Whenever the objects created in the heap, the java application needs to have a reference to hold it. Those references normally stores in stack.


Integrated Development Environment is a software application through which programmer can develop Java (or any other) programs, compile the programs and run the programs very easily. And the IDE itself contains tools Editor, Compiler, and Interpreter.


Eclipse, JDeveloper, Net Beans etc…

Class :

Classes are the fundamental building blocks of a Java program. A class is a template that describes the kinds of state and behavior that objects of its type support. Class represents the structure of the object. Class is used to as a blue print to create the object. The blue print describes the state and behavior of the objects. In Java, Class can be declared with the keyword called “class”.

class Student
int studentID;
public int getStudentID ()
return studentID;

In the above program Student represents the class, studentID is a class member or object state and getStudentID () is a member method represents the object behavior.

IMPORTANT : Class name (Here is Student) should starts with Capital letter.

Object :

An object has its own state and behavior. For ex, in real world Bicycle is an Object it has its own state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes). An object is an instance of a class. A class represents the structure of the object.

Creating the Java object for above Student class is as follows

Student student = new Student ();

Here, Student (Starts with Capital letter) is a class name.
student (Starts with small letter) is object name. It’s an instance of a class.

Instance Variable (State) :

An instance variable is a variable which is declared in the class. It represents the State of the object. The variable declared in the method is called as Local variable. We see the differences between these two and more about the variable later in this tutorial.
In the above example studentID represents the state of the object or it’s called as instance variable.

IMPORTANT : It is recommended that Instance variables or any variable names should starts with small letter. If variable name contains 2 words, the first word should starts with small letter second word should starts with capital letter. It’s called as Camel Case.

Methods (Behavior) :

A method is a function defined in the class. It represents the behavior of the object.A method is a block of code which does some specific operations.

In the above example getStudentID () represents the behavior of the object. It’s called as Method.

IMPORTANT : It is recommended that method names should starts with small letter. If method name contains 2 words, the first word should starts with small letter second word should starts with capital letter. It’s called as Camel Case.

Constants :

Java constants are values which we cannot change during the execution of the program. Java constants are created by marking variables static and final. They should be named using uppercase letters with underscore characters as separators.

Ex: public static final MAX_PRIORITY = 10;

Comment :

A Java comment is used by the programmer to understand the block of instructions. The Java comments are ignored by the java compiler to compile.

There are 3 types of comments in Java.

  1. Block Comment :

    A Block comment is a comment used to comment more than one line.

  2. Single line comment :

    It is used to comment single Java line.

  3. Document Comment :

    The comment which is used to generate the Javadoc is called Document Comment.

Block Comment :

Java instruction 1
Java Instruction 2
Java Instruction 3

Single line Comment :

// Java Instruction

Document Comment :
* @author Kranthi
* @version 1.1
* @since 1.0
class Main
public static void main (String [] args)
Source File :

A java source file is a file with the extension of “.java”. The source file contains the entire program with classes written by the programmer. To compile the java program, programmer has to save his/her file with the “.java” extension.

Class file :

A class file is a file with byte code. Java compiler compiles the source file or java file and generates the byte code in the class file. The class file saved with the “.class” extension. This class file is used to run the program by JVM.

Posted in Java Basics