JAVA BASICS


OBJECT ORIENTED LANGUAGE:


                              JAVA IS AN OBJECT ORIENTED LANGUAGE.What is object oriented language?.Which language has object oriented features(Polymorphism, Inheritance, Encapsulation and Abstraction) is called Object oriented language.

INHERITANCE:

                     One class acquire the properties of another class is called Inheritance.



POLYMORPHISM:
                              Polymorphism means many forms i.e one name used as many forms.

            example:

                       class PolyEx
                       {
                         private int a=5,b=10;
                         private float c=20.5f,d=35.7f;
                           
                                  public void sum(int x,int y)
                                  {
                                    System.out.println("Sum of Two Integers:"+(x+y));
                                    }
                                    public void sum(float r,float s)
                                    {
                                      System.out.println("Sum of Two Floats:"+(r+s));
                                      }
                                     public void call()
                                     {
                                         sum(a,b);
                                         sum(c,d);
                                         }
                               public static void main(String args[])
                               {
                                 PolyEx p=new PolyEx();
                                         p.call();
                                  }
                              }

               In this example sum is a method is used two times. First it takes two integers and perform sum then it takes floats.But the method name is same.It is called  Polymorphism(static).