What are the different categories of Inheritance?

 Posted by Manicse on 10/12/2016 | Category: OOPS Interview questions | Views: 147 | Points: 40
Answer:

Inheritance in OOP is of four types :

Single inheritance : Contains one base class and one derived class.
Example :
public class Base

{
}
public class Derived: Base
{
}
Hierarchical inheritance : Contains one base class and multiple derived classes of the same base class.
Example:

public class Base

{
}
public class Derived1: Base
{
}

public class Derived2: Base
{
}


Multilevel inheritance : Contains a class derived from a derived class.
Example:

public class Base

{
}
public class Derived1: Base
{
}

public class Derived2: Derived1
{
}


Multiple inheritance : Contains several base classes and a derived class.

Example:

public class Base1

{
}
public class Base2
{
}

public class Derived1: Base1,Base2
{
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response