blog

Home / DeveloperSection / Blogs / Concept of Inheritance

Concept of Inheritance

Anonymous User3723 07-Oct-2010
Inheritance:

In object-oriented programming, inheritance is the concept that when a class of objects is defined, any subclass that is defined can inherit the definitions of one or more general classes. This means for the programmer that an object in a subclass need not carry its own definition of data and methods that are generic to the class (or classes) of which it is a part. This not only speeds up program development; it also ensures an inherent validity to the defined subclass object (what works and is consistent about the class will also work for the subclass).

Sometimes base class known as generalized class and derived class known as specialized class.
Example:
Class x
{
    Public static int add (int a,int b)
    {
        Return (a+b);
    }
}
Class y:X
{
    Public static int mul(inta,intb)
    {
        Return(a*b);
    }
}
Static void main()
{
    X obj=new y();
    Obj.add(5,6);
}

Updated 18-Sep-2014
I am a content writter !

Leave Comment

Comments

Liked By