Class 12 Computer Science Important Questions (ASSEB / AHSEC)

Chapter 5 - Inheritance in C++

1. What is Inheritance?

Answer : The process of creating a new class from an existing class is called Inheritance. The new class acquires the properties (data members) and behaviors (member functions) of the existing class and can add additional features of its own.

2. What is the need for Inheritance?

Answer : Inheritance is necessary because :

  • It promotes code reusability
  • Reduces duplication of code
  • Saves programming time
  • Makes programs easier to modify
  • Simplifies maintenance

3. What is a base class?

Answer : A base class is a class whose properties are inherited by another class. Also called Super Class or Parent Class

4. What is a derived class?

Answer : A derived class is a class that inherits properties from another class. Also called Sub Class or Child Class)

5. What are the types of Inheritance?

Answer : C++ supports five types of inheritance

1. Single Inheritance

When a subclass inherits only from one base class, it is called Single Inheritance

single-inheritance

Here A is the base class and B is the derived class.

2. Multiple Inheritance

When a subclass inherits from multiple base classes, it is known as Multiple Inheritance

Multiple-inheritance

Here Class A and Class B are base classes and Class C is a derived class. Class C inherits the properties of both class A and class B.

3. Multilevel Inheritance

When a subclass is derived from another derived class, it is called Multilevel Inheritance

multilevel-inheritance

Here Class A and Class B are base classes and Class C is a derived class. Class C inherits the properties of both class A and class B.

4.Hierarchical Inheritance

When multiple subclasses inherit from a single base class, it is called Hierarchical Inheritance.

hierarchical-inheritance

Here Class A is the base class and Class B and Class C are derived classes.Both Class B and class C inherits properties from Class A.

5.Hybrid Inheritance

A combination of two or more types of inheritance, is called Hybrid Inheritance

hybrid inheritance

Here class A acts as the base class as Class B and C inherit from Class A. Class D on the other hand, inherits from both Class B and C

6. What is Visibility mode or Inheritance mode?

Answer :When inheriting, the visibility modes controls how the members of the base class are available and visible in the derived class. 

7. What are the three visibility modes?

Answer :There are three visibility modes

  • Public
  • Private
  • Protected

8. What is public Inheritance?

Answer :In public inheritance:

  • public members of base class becomes public in derived class
  • protected members of base class becomes protected in derived class
  • private members are not accessible directly

9. What is Protected Inheritance

Answer :In protected inheritance:

  • public members of base class becomes protected in derived class
  • protected members of base class becomes protected in derived class
  • private members are not accessible directly

10. What is private Inheritance?

Answer :In private inheritance:

  • public members of base class becomes private in derived class
  • protected members of base class becomes private in derived class
  • private members are not accessible directly

11. What are the advantages of Inheritance?

Answer :

  • Promotes code reusability
  • Eliminates duplicate code
  • Makes maintenance easier
  • Supports software extension
  • Saves development time
  • Represents real-world relationships effectively
Scroll to Top