COMPUTER SCIENCE INHERITANCE

DELHI 2006:

2.a) Define Multilevel and Multiple inheritance in context of Object Oriented Programming. Give suitable example to illustrate the same.

2

Ans:
Multilevel Inheritance: When a subclass inherits from a class that itself inherits from another class, it is known as multilevel inheritance.


Eg: (for Multi Level Inheritance)

class A
{
-----
------
}
class B:public class A
{
-----
-----
}
class C:protected B
{
-----
-----
}

Multiple Inheritance: When a sub class inherits from multiple base classes, it is known as multiple inheritance.

Eg: (for Multiple Inheritance)
class A
{
-----
------
}
class B
{
-----
-----
}
class C:public A,protected B
{
-----
-----
}

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( [email protected] )