Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  Chapter : Inheritance, Semester, Engineering

Chapter : Inheritance, Semester, Engineering - Computer Science Engineering (CSE) PDF Download

Inheritance

The Slide Covers :

What is Inheritance

Types Of  Inheritance

Public, Private, Protected

 

What is Inheritance

The mechanism of deriving a new class from an old one is called inheritance or derivation.

Definition of Inheritance:
Inheritance is the mechanism which allows a class A to inherit properties of a class B.

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

 

Types of Inheritance:

Single inheritance

Multiple inheritance
 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

 

Hierachical Inheritance:

Chapter : Inheritance, Semester, Engineering - Computer Science Engineering (CSE)

 

Multilevel Inheritance:

Chapter : Inheritance, Semester, Engineering - Computer Science Engineering (CSE)

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Hybrid Inheritance:

Chapter : Inheritance, Semester, Engineering - Computer Science Engineering (CSE)

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Advantages of Inheritance:

The major advantage is the reusability. Once a base class is written and debugged,it need not be touched again,but can be used to work in different.
It also reduces the frustration in complex programming.
Reusing exiting code saves time.

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Disadvantages of Inheritance:

The larger the inheritance model gets, the “wider” the mapped table table gets, in that for every field in the entire inheritance hiearchy, a column must exit in the mapped table.

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Private, Public, Protected :

Public:
Exp: class A
{
Public:
Int x;
Private:
Int y;
};
Class B : public A
{
Private:
Int p;
}

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Private, Public, Protected :

Chapter : Inheritance, Semester, Engineering - Computer Science Engineering (CSE)

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Private Inheritance :

Exp:class a
{
Private:
Int x;
Public:
Int y; };
Class B : private A
{
Int p; };

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Protected :

Exp:
Class A : protected B
{
Private : int X;
};

 

Inheritance----------------------------------------- Next Slide------------------------------- Hardeep Singh

Abstract class

 

An abstract class is one that is not used to create objects.an abstract class is used only for base class.
 

The document Chapter : Inheritance, Semester, Engineering - Computer Science Engineering (CSE) is a part of Computer Science Engineering (CSE) category.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)

Top Courses for Computer Science Engineering (CSE)

FAQs on Chapter : Inheritance, Semester, Engineering - Computer Science Engineering (CSE)

1. What is inheritance in computer science engineering?
Ans. Inheritance is a fundamental concept in computer science engineering, specifically in object-oriented programming. It allows a class to inherit properties and behaviors from another class, known as the parent or base class. This enables code reuse, as the derived or child class can inherit and extend the functionality of the parent class.
2. How does inheritance improve code reuse in computer science engineering?
Ans. Inheritance facilitates code reuse in computer science engineering by allowing derived classes to inherit properties and behaviors from a base class. This means that the derived class does not need to redefine or implement the common functionalities, as they are already present in the base class. By inheriting and extending the base class, developers can save time and effort in writing new code and maintain a more organized and modular codebase.
3. What are the types of inheritance in computer science engineering?
Ans. In computer science engineering, there are several types of inheritance: 1. Single Inheritance: A derived class inherits from a single base class. 2. Multiple Inheritance: A derived class inherits from multiple base classes. 3. Multilevel Inheritance: A derived class inherits from another derived class, forming a hierarchy. 4. Hierarchical Inheritance: Multiple derived classes inherit from a single base class. 5. Hybrid Inheritance: A combination of multiple and multilevel inheritance, involving multiple base and derived classes.
4. What is the significance of protected access specifier in inheritance?
Ans. In inheritance, the protected access specifier plays a significant role. When a member variable or function is declared as protected, it can be accessed by the derived class. This allows the derived class to inherit and utilize the protected members of the base class. However, protected members are not accessible by classes outside the inheritance hierarchy. Protected access specifier ensures encapsulation and maintains the integrity of the base class while allowing derived classes to access and modify the protected members.
5. How does inheritance contribute to polymorphism in computer science engineering?
Ans. Inheritance is closely related to polymorphism in computer science engineering. Polymorphism refers to the ability of an object to take on many forms or have multiple behaviors. Inheritance enables polymorphism by allowing different derived classes to share a common interface or base class. This means that objects of different derived classes can be treated uniformly through the base class, enabling code flexibility and extensibility. Polymorphism enhances code readability, maintainability, and modularity in software development.
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Summary

,

Sample Paper

,

shortcuts and tricks

,

Objective type Questions

,

pdf

,

Chapter : Inheritance

,

Semester

,

Engineering - Computer Science Engineering (CSE)

,

Semester

,

Semester

,

Chapter : Inheritance

,

video lectures

,

Engineering - Computer Science Engineering (CSE)

,

Semester Notes

,

Important questions

,

Extra Questions

,

Viva Questions

,

ppt

,

Exam

,

mock tests for examination

,

past year papers

,

Free

,

Engineering - Computer Science Engineering (CSE)

,

study material

,

MCQs

,

Previous Year Questions with Solutions

,

Chapter : Inheritance

,

practice quizzes

;