Home » Features of Object Oriented Programming

Features of Object Oriented Programming

OOP stands for Object Oriented Programming and the language that support this Object Oriented programming features is called Object oriented Programming Language. An example of a language that support this Object oriented features is C++.

FEATURES OF OOP:

  1. Object
  2. Class
  3. Encapsulation
  4. Inheritance
  5. Reusability
  6. Polymorphism
  7. Dynamic Binding
  8. Message Passing

Object: Object is a collection of number of entities. Objects takes space in the memory. Objects are instances of classes. When a program is executed , the objects communicate by sending messages to one another. Objects can interact without having know details of each others data or code.

Class: Class is a collection of objects of similar type. Objects are variables of the type class. Once a class has been defined, we can create as many objects belonging to that class. Also, class are user-defined data types.

Example:

days sunday, monday, tuesday ;

In the above statement sunday, monday, tuesday are the object which belong to the class days.

In other words, classes acts as data types for objects

Encapsulation: One of the most fundamental concepts of object oriented programming is encapsulation. Combining data and functions into a single unit called class and the process is known as Encapsulation. Data encapsulation is important feature of a class. Class contains both data and functions. Data is not accessible from the outside world and only those function which are present in the class can access the data.

Inheritance: Inheritance is the capability of a new class to inherit the data and functions of the old class without knowing the details of old class. The new class is known as derived class and the old class is known as base class. The derived class not only inherits some characteristics from its base class but also adds some new features of its own. The set of base class and derived class instances is referred as the class inheritance hierarchy.

Example: A typical example of inheritance:

In this example, Vehicle is the base class and Two wheeler, Three wheeler and Four wheeler are the derived classes.

Reusability:  The concept of inheritance provides an important extension to the idea of reusability. Reusability is nothing but re- usage of structure without changing the existing one but adding new features or characteristics to it. It is very much needed for any programmers in different situations.

The main advantages of reusability that it helps in reducing the code size since classes can be just derived from existing one and one need to add only the new features and it helps users to save their time.

Polymorphism: Polymorphism means that ability to take more than one form. So Polymorphism as the name suggests is a certain item appearing in different forms or ways. Polymorphism allows a user to create multiple definitions for operators and functions at run-time depending on the context a particular definition is used. In other words, polymorphism is the ability for a data to be processed in more than one form or you can say that different objects react in different manner to the same operation.

Polymorphism can be achieved by using two ways:

  • Operator Overloading
  • Function Overloading

Dynamic Binding: Binding is performed either at compile time or at run time. The binding which is done at compile time is known as static binding(early binding) and the binding which is done at run time is known as dynamic binding(late binding). Dynamic binding refers to linking of function call with function definition is called binding and when it is take place at run time called dynamic binding.

Message Passing: The process by which one object can interact with other object is called message passing.

In other words, we can say that message passing is the idea of sending message to an object, causing it to perform an operation by invoking the appropriate function of the object.


Leave a comment

Your email address will not be published. Required fields are marked *