English

What is inheritance? Explain with an example.

Advertisements
Advertisements

Question

What is inheritance? Explain with an example.

Explain
Advertisements

Solution

Inheritance is the process of creating a new class, called the derived class, from an existing class, called the base class. The derived class can use the data members and methods of the base class and may also add its own features.

Example: Mobile_phone can be a base class and i_phone can be a derived class. An iPhone has all common features of a mobile phone, such as model, colour and price, along with its own special features.

This represents an “is-a-kind-of” relationship: an iPhone is a kind of mobile phone.

shaalaa.com
  Is there an error in this question or solution?
Chapter 2: Concept of Object Oriented Programming - EXCERCISE [Page 37]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 2 Concept of Object Oriented Programming
EXCERCISE | Q 4. | Page 37
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×