Friday, 24 May 2013

CONCEPT OF OOPS (Object-Oriented Programming )

CONCEPT OF OOPS -OBJECT ORIENTED PROGRAMMING  

What is Abstraction,Encapsulation,Inheritance,Polymorphism?

  •   ABSTRACTION: Abstraction means to show only the necessary details and hiding non essential features. Abstraction is done when we need to inherit from certain class but do not instantiate the objects of that class. 
  •   ENCAPSULATION  : Encapsulation is wrapping/binding up of data and member functions  in single unit. 
In simple, abstraction is hiding the implementation and encapsulation is to hide data.
  •   INHERITANCE   : Inheritance  enables you to create new classes   that reuse ,extend  and modify the behaviour that is defined in other classes.  In simple terms when one class inherit the  properties , methods etc. of the other class is known as inheritance.  The class whose members are inherited are called base class and other class is known as derived class . 
      for eg : using system ;
                    public class baseclass{
                   public class baseclass( ) 
                   { console.writeline("this is base class constructor");}
                   public void  hello( )
                  { console.writeline("this is baseclass");}
                   }
                   public class derivedclass: baseclass
                    {public dervedclass(  )
                    console.writeline("this is derivedconstructor");
                    }
                    public static void main( )
                    { derivedclass obj = new derivedclass();
                      obj.hello( ); 
                     }
 OUTPUT : this is baseclass constructor 
         this is  derived constructor
         this is   baseclass 
    
                    

  •   POLYMORPHISM  : When an object exhibits different  behaviour in different situation. In simple way  when a message  can be processed in different ways/forms .   

      Polymorphism is of two types : Compile time polymorphism   (this is concept   

      of  OVERLOADING).      

    Runtime Polymorphism : (this is concept of OVERRIDING).