2015
Java Notes For Java Beginner
Inner classes

Inner classes :

To define one class into another, this process is called as inner classes.

There are four type of inner classes
1) Member inner class.
2) Static inner class.
3) Local inner class.
4) Anonymous inner class.


Member inner class :

A class which is defined as a member of some outer class is called as member inner class.

Write a program to define the member in inner class.
class outer
{
 int x=10;
 void fun1()
 {
  System.out.println("Hello outer class method");
 }
 class inner
 {
  int y=20;
  void fun2()
  {
   System.out.println("Hello inner class method");
  }
 } //inner class end
 
 public static void main(String args[])
 {
  outer a1=new outer();
  System.out.println("a1.x");
  a1.fun1();
  
  //a1.fun2();error
  //Inner il=new Inner();error
  
  outer.Inner i2=new Outer().new Inner();
  System.out.println(i2.y);
  
  //il.fun1();error
 }
} //outer class end

Static inner class :

Inner classes can be static we can instantiate this class directly or by the outer class name.
Write a program to define the static inner class.
class outer
{
 static int x=10;
 void fun1()
 {
  System.out.println("Hello outer class method");
 }
 static class inner
 {
  int y=20;
  void fun2()
  {
   System.out.println("Hello inner class method");
  }
 } //inner class end
 
 public static void main(String args[])
 {
  outer a1=new outer();
  System.out.println("X is "+x);
  System.out.println("X is "+a1.x);
  a1.fun1();
  
  Inner i=new Inner();
  System.out.println("Y is "+i.y);
  i.fun2();
 // OR
  outer.Inner il=new outer.inner();
  System.out.println("Y is "+il.y);
  il.fun2();
 }
} //outer class end

Local inner class :

A class which is defined in method body of outer class, this is called as local inner class. The scope and accessibility of this class is limited up to the method in which it is defined.
Write a program to define the local inner class.
class outer1
{
 int y=20;
 void fun1()
 {
  System.out.println("Enter into method");
  
  class local
  {
   int x=50;
   void fun2()
   {
    System.out.println("Hello local class method");
   }
  };
  
 local L1=new local();
 System.out.println("X is "+L1.x);
 L1.fun2();
 System.out.println("Exit from method");
 } //fun1

 public static void main(String args[])
 {
  outer1 a1=new outer1();
  System.out.println("Y is "+a1.y);
  a1.fun1();
 }
} //outer class end

Anonymous inner class :

A local inner class, which does not have name and implements the outside interface, is called as anonymous inner class.
Write a program to define the anonymous inner class.
interface xyz
{
 public void fun1();
 public void fun2();
}
class test
{
 public xyz getxyz1()
 {
  xyz x1=new xyz()
  {
   public void fun1()
   {
    System.out.println("Hello first class fun1");
   }
   public void fun2()
   {
    System.out.println("Hello first class fun2");
   }
  };
 return(x1);
 } //getxyz1
 
 public xyz getxyz2()
 {
  xyz x2= new xyz()
  {
   public void fun1()
   {
    System.out.println("Hello second class fun1");
   }
   public void fun2()
   {
    System.out.println("Hello second class fun2");
   }
  };
 return(x2);
 } //getxyz2
 public static void main(String args[])
 {
  Test t1=new Test();
  xyz x3=t1.getxyz1();
  xyz x4=t1.getxyz2();
  
  x3.fun1();
  x3.fun2();
  
  x4.fun1();
  x4.fun2();
 }
}


class AB
{
 {
  System.out.println("Non static block");
 }
 static
 {
  System.out.println("static block");
 }
 
 AB()
 {
  System.out.println("Constructor block");
 }
 
 fun1()
 {
  System.out.println("Method block");
 }
 
 public static void main(String args[])
 {
  System.out.println("Main block");
  
  AB a1=new AB();
  a1.fun1();
  
  AB a2=new AB();
 }
}

static block
Main block
Constructor block
Method block

Non static block
constructor block
Java Notes For Java Beginner
Abstract And Final Class

Abstract class

  • A partially implemented and partially unimplemented class, is called as abstract class.
  • Definition : A class which have at least one abstract method, is called as abstract class explicitly.
  • Keyword abstract is used to declare this class explicitly, Abstract class cannot be instantiated because it may have abstract method.

Write a program to define abstract class execution.
abstract class Abs1
{
 public void fun1()
 {
  System.out.println("Hello abstract class method");
 }
 abstract public void fun2();
}

class Abs extends Abs1
{
 public void fun2()
 {
  System.out.println("Hello fun2 sub class method");
 }
 
 public static void main(String args[])
 {
  Abs a1 = new Abs();
   a1.fun1();
   a1.fun2();
  Abs1 a2 = new Abs();
   a1.fun1();
   a1.fun2();
 }
}



Abstract class can created in 3 ways:
1) Declare abstract method in class.
2) Declare keyword 'abstract' with class.
3) Do not implement the interface completely.

Final class:

  • A class which can Inherit others but cannot be inherited by other is called final class.
  • Keyword "final" is used to declare final class explicitly.
  • final class is the last class of inheritance chain.
Write a program implement final class execution.
final class fin extends object
{
 public void fun1()
 {
  System.out.println("Hello final class method");
 }
}
class fun1
{
 public void fun2()
 {
  System.out.println("Hello sub class method");
 }
 public static void main(String args[])
 {
  fin1 f1=new fin1();
  //f1.fun1();
  f1.fun2();
  fun f2=new fun();
  f2.fun();
 }
}


Difference between abstract and final class.
1) Abstract class cannot be instantiated.
2) Abstract class should be inherited in some other class.
3) Abstract class may have abstract methods.
4) Super class reference and sub class object concept is followed by abstract.
5) Abstract keyword is used to declare this class
1) The object creation process of final class is compulsory.
2) final class cannot be inherited.
3) final class doesnot have abstract method.
4) this concept is not followed by final class.

5) final keyword is used to declare this class.


Note : The class can be either abstract or final.


abstract
final
static
  • class
  • variables
  • methods
  • constructor
Java Notes For Java Beginner

We can create the reference of super class and assign the sub class object to it. The execution behavior of this reference variable is depends upon the super class. But the execution is like basic interface.

Super class reference & sub class object
class A
|
♦-- Fun1, Fun2, FunX
|

class B
|
♦-- Fun2, FunB, FunN
|

class C
|
♦-- Fun1, FunX, Fun3
|

class D
|
♦-- FunN, FunB, Fun3
|

D d1 = new D();
d1.fun1(); //C
d1.fun2(); //B
d1.funN(); //D

C c1 = new C();
c1.funN();
c1.fun1();
c1.fun2();

A a1 = new D();
a1.fun1(); //C
a1.fun2(); //B

//a1.funN(); error
a1.funX(); //C

B b1=new C();
b1.funX(); //C
b1.funb(); //B

D d1=new A(); //Note possible
The sub class reference and super class object cannot is not possible because this object doesn't fulfill the context requirement of sub class refernece.


Write a program of dynamic polymorphism.

class AA
{
 void AA()
 {
  System.out.println("Hello class AA method");
 }
}
class BB extends AA
{
 void BB()
 {
  System.out.println("Hello class BB method");
 }
}
class CC extends BB
{
 void fun1()
 {
  System.out.println("Hello sub class CC method");
 }
 
 public static void main(String args[])
 {
  int n=args.lenth;
  
  if(n>0)
  {
   AA.a1;
   int a=Integer.parseInt(args[0]);
   switch(a);
   {
    case 1:{
       d=new AA();
       break;
        }
    case 2:{
       a1=new BB();
       break;
        }
    case 3:{
       a1=new CC();
       break;
        }
    default:{
       System.out.println("Invalid Arguments");
       a=new AA();
       break;
      }
   }
  a1.fun();
  }
  else
  {
   System.out.println("Please enter arguments");
  }
 }
}
Java Notes For Java Beginner

Interface

Interface in javaA special type of class, which is used to declare only abstract methods is called as interface.

Keyword "interface" is used to define this class.

Keyword "implemets" is used to inherit the interface into classes.

interface xyz
{
 public void fun1();
 public void fun2();
}
class A implements xyz
{
 public void fun1()
 {
  System.out.println("Hello Function 1");
 }
 public void fun2()
 {
  System.out.println("Hello Function 2");
 }
 public void fun3()
 {
  System.out.println("Hello Function 3");
 }
 
 public static void main(String args[])
 {
  A a1=new A();
  a1.fun1();
  a1.fun2();
  a1.fun3();
 }
}


Note : One class can implements more than one interface.

Example :
Class A implements xyz, pqr, abc.
It look like multiple inheritance but it is not actually.

IMP Note :
By default all the elements declared in interface are in public.



Final keyword :

Keyword "final" is used to create constant in Java program. The values of these variables are never changed at runtime.

Example :
final int x=3;
x=5; // error
x=3; // error
x++; // error

IMP Note :
By default the interface variables are public, static and final.

interface ABC
{
 public final static int x=10;
 int y=20;
}
class B implements ABC
{
 public static void main(String args[])
 {
  B b1=new B();
  
  System.out.println("X is "+b1.x);
  System.out.println("Y is "+b1.y);
  
  // b1.X=50;  error
  // b1.Y=100; error
  
  System.out.println("X is "+ABC.x);
  System.out.println("Y is "+ABC.y);
 }
}

Java Notes For Java Beginner

Inheritance:

The concept of reutilazation is called as inheritance.
Inheritance is used to eliminate the reduandancy of program.


Note : Keyword "extends" is used to inherit one class into another class.

The class which gives it's properties to another class is called as super class or base class.
The class which takes properties from other class is called as sub-class or derived class.

Syntax:
class B extends A
{
-----
-----
}

Types of inheritance

1] Single inheritance :

The one to one communication between super and sub class, this concept is called as single inheritance.

/*Example of simple inheritance */
class A
{
 void fun1()
 {
  System.out.println("Hello this is Super class method");
 }
}
class B extends A
{
 void fun2()
 {
  System.out.println("Hello this is Sub class method");
 }
 
 public static void main(String args[])
 {
  A a1=new A();
  B b1=new B();
  
  a1.fun1();
  b1.fun2();
  b1.fun1();
 }
}


2] Multilevel inheritance :

To inherit more than one classes in chain format with a finite termination, this concept is called as multilevel inheritance.

Tip [Rule] message : One java class can extends only one java class.
According to this rule, Java doesn't follow multiple, Multi-path and Hybrid inheritance.

Note : Class object is the super must built in class of java hierarchy. Every built in and user defined classes should inherit the object class. This class provides the context creation, constructor calling, data overloading and execution properties to the object creation statement.


JAVA Does not Follow The Cyclic Inheritance.

Constructor are executed in the manner they are defined in inheritance


Write a program to define the constructor execution inheritance.

class A extends object
{
 A()
 {
  System.out.println("Class A Constructor");
 }
}
class B extends A
{
 B()
 {
  System.out.println("Class B Constructor");
 }
}
class C extends B
{
 C()
 {
  System.out.println("Class C Constructor");
 }
}
class D extends C
{
 D()
 {
  System.out.println("Class D Constructor");
 }
 
 public static void main(String args[])
 {
 D d1=new D();
 C c1=new C();
 B b1=new B();
 A a1=new A();
 }
}



Super


Note : Kayword 'super' is used to call the super class parameterized constructor from sub class constructor.

"Super" should be the first statement of constructor body.

Write a program to call the super class default and parameterized constructor from sub class.

class A
{
 A()
 {
  System.out.println("Class A constructor");
 }
 A(int a)
 {
  System.out.println("A is "+a);
 }
}
class B extends A
{
 B()
 {
  System.out.println("Class B constructor");
 }
 B(int b)
 {
  System.out.println("B is "+b);
 }
}
class C extends B
{
 C()
 {
  System.out.println("Class C constructor");
 }
 C(int c)
 {
  System.out.println("C is "+c);
 }
 
 public static void main(String args[])
 {
 C a1=new C();
 }
}


Java program execution criteria :


JVM loads all the static data of class into memory. At last it loads the main method. But executes the main() method first to all main() method creates objects.
Object's call the constructor creates context for remaining non-static data of class. It loads this data into newly created context and assign the control to the object.

Method overriding :


To define the same name method with same signature and same arguments in super class as well as in sub class, this concept is called as method overloading.

Note : Keyword "super" is used to call the super class overrided method from sub class method.

Write a program to define methods overriding.

class P
{
 void fun1()
 {
  System.out.println("Hello super class method");
 }
}
class Q extends P
{
 void fun1()
 {
  Super.fun1();
  System.out.println("Hello Sub class method");
 }
 public static void main(String args[])
 {
  Q q1=new Q();
  q1.fun1();
 }
}
Java Notes For Java Beginner

Primitive data types:


There are four primitive data types in JAVA.


Interger - byte, short, int, long
Real Number - float, double
Character - char
Boolean - boolean


Write a program to print by default value of all the primitives..
class Type
{
 byte a;
 short b;
 int c;
 long d;
 float e;
 double f;
 char g;
 boolean h;
 
 public static void main(String args[])
 {
 Type t1 = new Type();
 
 Syste.out.println("byte default value is "+t1.a);
 Syste.out.println("short default value is "+t1.b);
 Syste.out.println("int default value is "+t1.c);
 Syste.out.println("long default value is "+t1.d);
 Syste.out.println("float default value is "+t1.e);
 Syste.out.println("double default value is "+t1.f);
 Syste.out.println("char default value is "+t1.g);
 Syste.out.println("boolean default value is "+t1.h);
 }
}
Java Notes For Java Beginner
A special type of method, which is used to construct memory for class elements, is called as constructor.

Example :
class A
{
 A()
  {
  }
}


It's specialties are

  • It's name and class name is same.
  • It executes implicitly on object creation statements.
  • Constructors cannot be executed explicitly by objects that one constructor in it's life time.
  • Constructor doesn't have any return type not even void


Example :
class AB
{
 AB()
 {
  System.out.println("Hello Constructor");
 }
 public static void main(String args[])
 {
  AB a1=new AB();
  AB a2=new AB();
  AB a3=new AB();
  AB a4=new AB();
  }
}


Types of Constructor :

There are two types of constructor in Java.

1.Default Constructor :

A constructor which does not accept arguments, is called the default constructor.

Parameterized Constructor :

A constructor which have parameters and accepts arguments at runtime is called as parameterised constructor.


Write a program to define constructors overloading.
class ABC
{
 ABC()
 {
  System.out.println("Default constructor");
 }
 ABC(int x)
 {
  System.out.println("X is "+x);
 }
 ABC(float p)
 {
  System.out.println("P is "+p);
 }
 ABC(int a,int b)
 {
  System.out.println("A is "+a+" B is "+b);
 }

public static void main(String args[])
 {
 ABC a1= new ABC();
 ABC a2= new ABC(100);
 ABC a3= new ABC(12.5);
 ABC a4= new ABC(1,10);
 }
}


Construction execution criteria[Process] :

There are four steps in execution criteria of Constructor.
  1. TO create context.
  2. To load the class data into that context.
  3. To initialize all the uninitialized data of context.
  4. To execute it's own body.

Java Notes For Java Beginner
To define the same name method for more than one time in one class with same signature and different arguments this concept is called as method overloading.


Signature means : [In Java]
Access specifiers, Return type and method name.


Write a program to define methods overloading.


class over
{
 void fun1
 {
  System.out.println("No argumented method");
 }
 void fun1(int x)
 {
  System.out.println("X is "+x");
 }
 void fun1(int a,int b)
 {
  System.out.println("A is "+a+" B is "+b);
 }
public static void main(String args[])
 {
  over o=new over();
  o.fun1();
  o.fun1(10);
  o.fun1(10,20);
 }
}

Java Notes For Java Beginner

Access specifiers

Java have four access specifiers.
  • public :
    • The keyword which is used a access specifier whose data can be accessible in same class, other class, other program, other folder, other colon and even other machine.
    • Java follows client-server architecture, so main() method should be public.
  • private :
    • The stronger access specified which restricts the data to be come out of class.
    • Private data can not be accessible even through it's class object.
  • protected :
    • The partial public and partial private access specifier.
    • It follows public property as the data can be come out of the class but only in inheritance.
    • It private property can not be accessible through class object.
  • default :
    • It is not keyword.
    • It works same as public up-to one working folder.
    • Otherwise it becomes private.


Static

Static keyword is used to load the main method into primary memory by JVM[Java Virtual Machine].

void

This keyword is used as a return type of method is not going on return any value.

main

A flag which is used as indicator of starting point of program for compiler and inter-printer.
Java Notes For Java Beginner
The classes which are used to convert the string value (Actually numeric) into it's respective data type, are called as wrapper classes.


Classes
  • Integer
  • Float
  • Character
  • Long
  • Short
  • Byte
  • Boolean
  • Double
And there respective static parsing methods are :
  • parseInt()
  • parsefloat()
  • parselong()
  • parseShort()
  • parseDouble()
  • parseByte()
  • parseChar()
  • parseBoolean()


Integer.parseInt()

It converts the string value into integer type.

float.parsefloat()

It converts the string value into float type.


Write a program to print addition of two numbers passed through command line.

class Add1
{
 public static void main(String args[])
 {
  int n=args.length;
  if(n>1)
  {
  int a,b,c;
  a=Integer.parseInt(args[0]);
  b=Integer.parseInt(args[1]);
  c=a+b;
  System.out.println("Addition is "+c);
  }
         else
   System.out.println("Please enter two arguments");
 }
}

How To Run ?
javac Add1.java
java Add1 10 30
Java Notes For Java Beginner
The arguments which are passed through command line at run-time and which are stored in the array of string class in main method are called as command line arguments.

Write a program to pass command line arguments.

class E
{
 public static void main(String args[])
 {
  int n=args.length;
  int i;
  if(n>0)
  {
   for(i=0;i<n-1;i++)
   System.out.println(args[i]);
  }
  else
  {
   System.out.println("Please enter values");
  }
 }
}

How To Run ?
javac E.java
java E 123 567 NSB
Java Notes For Java Beginner
String : A built in class, whose object is used to store the set of characters, is called as string.

Example :
String S1=new String("Hello");
or
String S1="Hello";


String manipulation methods:

  1. length() :- This method is used to return the number of characters of a given string.
  2. trim() :-  This method is used to trim or remove the white spaces from Right Hand Side and Left Hand Side of given string.
  3. toUpperCase() :- This method is used to convert the given string in Upper case.
  4. toLowerCase() :- This method is used to convert the given string in Lower case. 
  5. equals() :- This method is used to compare two string according to there ASCII value for equality.
    [It returns true if both the string are same & otherwise return false]
  6. CompareTo() :- This method is also used to compare two string according to ASCII values.
    [It's return type is Integer]
    Example:
    int i=s1.compareTo(s2);

    if it return > 0 value then s2>s1
    if it return < 0 value then s1>s2
    if it return = 0 value then s1=s2

  7. CompareToIgnoreCase() :- It work is same as above method with ignoring the case sensitivity.


Write a program to implement all the methods of string class.

class str
{
 public static void main(String args[])
 
 {
  String s1="Good morning";
  System.out.println(s1);
  
  String s2=s1.trim();
  System.out.println(s2);
  
  System.out.println("length of s1="+s1.length());
  System.out.println("length of s2="+s2.length());
  
  String s3=s2.toUpperCase();
  String s4=s2.toUpperCase();
  System.out.println("S3= "+s3);
  System.out.println("S4= "+s4);
  
  if(s3.equals(s4))
  System.out.println("Both the string are same");
  else
  System.out.println("Both the string are not same");
  
  int i=s3.compareToIgnoreCase(s4);
   if(i<0 s4="" system.out.println="">s3");
   else if(i>0)
   System.out.println("s3>s4");
   else if(i==0)
   System.out.println("s3 = s4"); 
 }
}


Note : String is a native or peer class, so the changes occurred in same other location.

To perform the changes on same location, we have to follow the StringBuffer class.

It dynamically increment or decrements the size of String object.



StringBuffer class methods

  1. append(String) :- This method is used to join or append the new string in previous string.
  2. insert(index, string) :- This method is  used to insert the new string on the specified index of previous string.
  3. setCharAt(index, char) :- This method set or replace the specified index character with the new character.
  4. reverse() :- This method is used to convert the given string in reverse.


Write a program to implement all the methods of stringBuffer class.

class str1
{
 public static void main(String args[])
 {
  StringBuffer sb=new StringBuffer("Hello morning");
  System.out.println(sb);
  
  sb.append("Bye");
  System.out.println(sb);
  
  sb.insert(13, " ");
  System.out.println(sb);
  
  sb.insert(6, "Good");
  System.out.println(sb);
  
  sb.insert(10, " ")
  System.out.println(sb);
  
  sb.setCharAt(10,"_");
  System.out.println(sb);
  
  
  System.out.println(sb.reverse());
 }
}

Java Notes For Java Beginner

Array : A homogeous set of finit elements which is stored in a continues memory location under certain name, is called array.

Example:
int a[]=new int[5];
a[0] =4;
a[1] =6;
a[2] =8;
a[3] =10;
a[4] =15;

or

int a[]={4,6,8,10,15};


length: This field is used to return the number of elements of a given array.

Write a program to sort given array in ascending order using selection sort technique.

class sort
{
 public static void main(String args[])
 {
  int a[]={55,33,11,22,44}
  int n=a.length;
  int i,j,temp;
  System.out.println("Before swapping array elemts");
  
  for(i=0;i<=n-1;i++)
   System.out.println(a[i]);
   
   for(i=0;i<=n-2;i++)
   {
    for(j=i+1;j<=n-1;j++)
    {
     if(a[i]>a[j])
     {
      temp=a[i];
      a[i]=a[j];
      a[j]=temp;
     }
    }
   }
  System.out.println("Sorted array elements are :");
  System.out.println(a[i]);
 }
}
Java Notes For Java Beginner

Static keyword is used to load the class data into primary memory first to the object. As it is directly loaded into memory, it can be accessible directly.

Note : Static data is shareable to all the objects of same class.

Write a program to access static & non-static data of class.
class class

{
    int x; //non-static
    static int y; //static
    public static void main (String args[])
    {
        c c1=new c();               //New object created [1st]
        system.out.println(c1.x);   //called using c1 object
        system.out.println(c1.y);   //called using c1 object
        system.out.println(c.y);    //called using class
        system.out.println(x);      //directly called
 
        c1.x++;                     //Operation performed using c1 object [Value becomes x=1]
        c1.y++;                     //Operation performed using c1 object [Value becomes y=1]
       
        c c2=new c();               //New object created [2nd]
        system.out.println(c2.x);   //called using c2 object
        system.out.println(c2.y);   //called using c2 object
    }
}


Output:
           0
           0
           0
           0
           0
           1

Static data can be accessible by three ways.

  1. Using class object.
  2. Using class name.
  3. Directly.

Note : Non-static data can be accessible only through it's class object.

System.out.println() //Statement

System is a built in class and out is static field of it. The combination of this two will send the data from editor to keyboard memory. This memory is the space reserved on primary memory for every java application. The println() method of print stream class sends the data from keyboard memory to console.

PrintStream class have two methods

1> println(): This method send the corsor to the next line after printing the data.

Example:
class D
{
    public static void main(String args[])
    {
        System.out.println("\t\t Hello\t\t\t");
        System.out.println("How Are You?");
        System.out.println("Bye...");
    }
}

Output:
         Hello
    How Are You?
    Bye...

2> print(): It remains cursor on the same line after printing.


Example:
class add
{
    public static void main(String args[])
    {
        int a,b,c;
        a=10;
        b=20;
        c=a+b;
       
        System.out.println(C);
        System.out.println("Addition is "+c);
        System.out.println("Addition of "+a" and "+b" is "+c);
        System.out.println(a+" + "+b+" = "+c);
    }
}

Output:
    30
    Addition is 30
    Addition of 10 and 20 is 30
    10 + 20 = 30
   
Note : + sign is used as separator in system.out.println statement...



Java Notes For Java Beginner

Structure oriented language 'C' when implemented with new object oriented concepts, it becomes 'C++'.
These new language doesn't support/follow the concepts so C++ is also known as partial object oriented language. Both above languages are 16 bits (DOS-Base) application (Window based), implements all oops (object oriented programming) concept by removing the structural orientation from it. This new language is called 'OAK' It is Designed & Developed by the team whose leader is 'JAMES GOSLING' at 'SUN MicroSystems' USA in 1991.

Preliminary, this language is used for repairing & manufacturing of electronic equipment's like radio, transistor, press, etc... As this language follows better network, so the development team uses this application for chatting in Intranet process. This team creates a web browser for mailing of large data & named as 'Hot-JAVA'.

Later on, it comes into consideration, that this language is also applicable for academic purpose, So it again lunch at 1995 for the same purpose & Just renamed it as 'JAVA'. Java is famous for its slogan "Write Once, Run Anywhere."

There were five primary goals in the creation of the Java language:
  • It must be "simple, object-oriented, and familiar".
  • It must be "robust and secure".
  • It must be "architecture-neutral and portable".
  • It must execute with "high performance".
  • It must be "interpreted, threaded, and dynamic".

Java Versions:

  • JDK 1.0
  • JDK 1.1
  • J2SE 1.2
  • J2SE 1.3
  • J2SE 1.4
  • J2SE 5.0
  • Java SE 6
  • Java SE 7
  • Java SE 8 
Read More About Java version history here.

Features of JAVA

  • Java is secured language.
  • Java is complied and interpreted language.
  • Java is platform independent language [It means we can compile sthe java application on one machine and run it on other machine with same or other platform (operating system).
  • Java is famous for its slogan "WORA" means "Write Ones, Run Anywhere".
  • Java is Simple, Robust & Dynamic language.
  • Java is multi-threaded & distributed language.
  • 'javac' command is used to invoke the .java file to it. compiler converts it into it's equivalent .class file (Byte code).
  • 'Java' command is used to call the java interpreter (JVM-JAVA Virtual Machine), assign th .class file without extension to this command. It converts it into it's .exe file, print's the output & delete the .exe file from memory.
  • Program should be save with the class name in which main() method is defined.
  • Example: File Name: A.java
    class A
    {
    public static void main(String args[])
    {
    System.out.println("Hello");
    System.out.println("How Are You ? ");
    System.out.println("Bye... ");
    }
    }
    
  • Context Creation : Context means the memory created by object for the class elements.
  • Example: File Name: B.java
    class B
    {
    int x=10;
    int y;
    void fun1()
    {
    System.out.println("Hello Fun1");
    }
    public static void main(String args[])
    {
    B b1=new B();
    b1.fun1();
    b1.fun1();
    System.out.println(b1.x);
    System.out.println(b1.y);
    b1.y=50;
    System.out.println(b1.y);
    B b2=new B();
    System.out.println(b2.x);
    System.out.println(b2.y);
    b2.fun1();
    }
    }