0% found this document useful (0 votes)
13 views6 pages

Chapter 10 Inheritance

Uploaded by

hakerphan777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views6 pages

Chapter 10 Inheritance

Uploaded by

hakerphan777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 6

CHAPTER 10-INHERITANCE

One marks questions:


1. What is inheritance?
ANS: Inheritance is the capability of one class to inherit properties from another class.
2. How is inheritance implemented in C++?

ANS: C++ allows the user to create a new class (derived class) from an existing class (base class).
3. What is a base class?

ANS: Base Class is the class whose properties are inherited by another class. It is also called Super class.
4. What is derived class?

ANS: Derived Class is the class that inherits the properties from base class. It is also called Sub class.
5. Give any one advantage of inheritance?
ANS: Reusing existing code
6. What is singe level inheritance?
ANS: Single Inheritance is the process of creating a new class from existing class base class.
7. What is multilevel inheritance?
ANS: Derivation of a class from another derived class is called multilevel inheritance.
8. What is hierarchical inheritance?

ANS: If a number of classes are derived from a single base class, it is called as hierarchical inheritance.
9. What is hybrid inheritance?
ANS: Hybrid Inheritance is combination of Hierarchical and multilevel inheritance.

10. What is multiple inheritances?


ANS: A class can be derived from more than one base class is known as multiple inheritances.
11. When is it necessary to use inheritance?
ANS: Suppose X is a class already defined and we need to redefine another class Y which has same properties of X and
in addition its own.
12. What is visibility mode?
ANS: It specifies the availability of class members in other classes.
13. What is a super class?
ANS: Base Class or Super class is the class whose properties are inherited by another class.
14. What is a subclass?
ANS: Derived Class or Sub class is the class that inherits the properties from base class.
Two marks questions:
1. Write any two advantages of inheritance.
ANS: i) Reusing existing code
ii) Faster development time

iii) Easy to maintain

2. Mention any two types of inheritance?


ANS: i) Single Inheritance
ii) Multilevel Inheritance
3. What is single inheritance? Give an example.
ANS: Single Inheritance is the process of creating a new class from existing class base class.
class Base_Class
{

………..

};

class Derived_class : public Base_calss

………..
};

4. What is multilevel inheritance? Give an example?


ANS: Derivation of a class from another derived class is called multilevel inheritance.

5. What is hierarchical inheritance? Give an example. (U)

ANS: If a number of classes are derived from a single base class, it is called as hierarchical inheritance.
6. What is hybrid inheritance? Give an example.
ANS: Hybrid Inheritance is combination of Hierarchical and multilevel inheritance.

7. What is multiple inheritances? Give an example.


ANS: A class can be derived from more than one base class is known as multiple inheritance.

8. Write the syntax to define a derived class.


ANS: class derived_class_name : Visibility Mode base_class_name { ……. };

Three marks questions:


1. Write any three advantages of inheritance. (U)
ANS: i) Reusing existing code
ii) Faster development time
iii) Easy to maintain
iv)Easy to extend
v) Memory Utilization
2. Mention any three types of inheritance? (U)
ANS: 1) Single Inheritance
2) Multilevel Inheritance
3) Multiple Inheritance
4) Hierarchical Inheritance
5) Hybrid Inheritance
3. Mention the types of inheritance. Explain any one. (K)
ANS: i) Single Inheritance is the process of creating a new class from existing class base class.
ii) In Single inheritance a class is derived from the base class.
iii) The data members and member function of the base class can be accessed in the derived class.
A derived class with single inheritance is declared as follows:
class Base_Class
{
………….

};
class Derived_class : public Base_calss

………..

};

4. Explain public inheritance.


ANS: Public Inheritance:

i) When a base class is inherited as public, all public members of the base class become public members of

derived class.

ii) The private members of the base class are nor accessible by members of the derived class.
5. Explain private inheritance.
ANS: Private Inheritance:

i) When a base class is inherited as private, then all public and protected members of the base class become

private members of derived class.

ii) The private members of the base class are nor accessible by members of the derived class..
6. Explain protected inheritance.
ANS: Protected Inheritance:

i) When a base class is inherited as protected, then all public and protected members of the base class become

protected members of derived class.

ii) The private data members of base class are not visible to derived class.

Five marks questions:

1. Explain the different types of inheritance.

ANS: Inheritance: Inheritance is the capability of one class to inherit properties from another class.

Types of Inheritance:
i) Single Inheritance
ii) Multilevel Inheritance
iii) Multiple Inheritance
iv) Hierarchical Inheritance
v) Hybrid Inheritance

i) Single Inheritance: Single Inheritance is the process of creating a new class from existing class base class.
ii) Multilevel Inheritance: Derivation of a class from another derived class is called multilevel inheritance.

iii) Multiple Inheritance:


A class can be derived from more than one base class is known as multiple inheritance. A derived class with multiple
inheritance is declared as follows:

Hierarchical Inheritance:
If a number of classes are derived from a single base class, it is called as
hierarchical inheritance.
Hierarchical model exhibits top down approach by breaking up a complex
class into simpler class

Hybrid Inheritance:
Hybrid Inheritance is combination of Hierarchical and multilevel inheritance.
2. What are the advantages of inheritance? (U)
ANS: i) Reusing existing code
ii) Faster development time
iii) Easy to maintain
iv) Easy to extend
v) Memory Utilization
3. What is visibility mode? Explain private and public inheritance.
ANS: Visibility mode:

Visibility mode can be public, private or protected. The private data of base class cannot be inherited.
1) Public: If inheritance is done in public mode, public members of the base class become the public member of
derived class and protected member of base class become the protected member of derived class..
2) Private: If inheritance is done in a private mode, public and protected members of base class become the
private members of derived class.
3) Protected: If inheritance is done in a protected mode, public and protected members of base class become the
protected members of the derived class.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy