NCERT Computer: Chapter 8 – General Concept of OOP Part 3

Download PDF of This Page (Size: 189K)

4. Data Encapsulation

Image of Encapsulation

Image of Encapsulation

Image of Encapsulation

  • Encapsulation is the most basic concept of OOP.

  • It is the way of combining both data and the functions that operate on that data under a single unit.

  • These functions are considered as member functions in C++.

  • It is not possible to access the data directly.

  • If you want to reach the data item in an object, you call a member function in the object.

  • It will read the data item and return the value to you. The data is hidden, so it is considered as safe and far away from accidental alternation.

  • Data and its functions are said to be encapsulated into a single entity.

5. Modularity

The act of partitioning a program into individual components is called modularity. It gives the following benefits.

  • It reduces its complexity to some extent.

  • It creates a number of well-defined, documented boundaries within the program.

Module is a separate unit in itself. It can be compiled independently though it has links with other modules.

Modules work quite closely in order to achieve the program’s goal.

6. Inheritance

Image of Inheritance

Image of Inheritance

Image of Inheritance

  • It is the capability to define a new class in terms of an existing class.

  • An existing class is known as a base class and the new class is known as derived class.

  • Number of examples can be given on this aspect. For example, a motor cycle is a class in itself.

  • C++ supports such hierarchical classification of classes.

  • The main benefit from inheritance is that we can build a generic base class, i.e., obtain a new class by adding some new features to an existing class and so on.

  • Every new class defined in that way consists of features of both the classes.

  • Inheritance allows existing classes to be adapted to new application without the need for modification.

7. Polymorphism

Image of Polymorphism

Image of Polymorphism

Image of Polymorphism

Polymorphism is a key to the power of OOP. It is the concept that supports the capability of data to be processed in more than one form.

For example, an operation may exhibit different behaviour in different instances.

The behaviour depends upon the types of data used in the operation.

Let us consider the operation of addition. For two numbers, the operation will generate a sum.

If the operands are strings then the operation would produce a third string by concatenation.

Sign In