Basic Concepts of Object Oriented Programming

Object Oriented Programming:

Object-oriented programming or OOPs is a type of programming pattern where the programs are structured around objects rather than functions and logic. It is based on real-world entities like inheritance, polymorphism, data encapsulation, etc. OOPs represents the data as objects that have attributes and functions.

Concepts of Object Oriented Programming:

1. Class:

Classes are user-defined data types. The entire set of data of code and its object can be made a user-defined data type that is called class. A class is a collection of objects and user-defined data types. It has the following syntax:

class class-name

2. Object:

Object is the basic run-time entity in object-oriented programming. It represents a person or a table of data that handles the program. It may also represent user-defined data such as vectors and lists. When a program is executed, the objects interact by sending messages to one another.

3. Abstraction:

Abstraction refers to the act of representing essential features without including background details or explanations. It is defined as a list of abstract attributes such as size, weight, and cost, and functions to operate on these attributes.

4. Encapsulation:

The wrapping up of data and functions into a single unit is called encapsulation. Encapsulation is the most striking feature of a class. The data is not accessible to the outside world and only those functions which are wrapped in the class can access it.

5. Inheritance:

It is a process by which one class acquires the properties of objects of another class. In Concepts of OOP, Inheritance provides the idea of re-usability which means we can add additional features to an existing class without modifying it. It is possible to derive a new class from the existing class. The new class will have the combined features of both classes. The mechanism of inheritance is that it allows the programmer to reuse a class that is almost. It has the following syntax:

class derived-class_name :: base-class_name
{
// body of the derived class.
}

6. Polymorphism:

Polymorphism is a Greek term means that “one name, multiple forms“. It is an important concept of OOPs. Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface which means a general class of operations may be accessed in the same manner even though specific actions are associated with each operation. There are two types of polymorphism in OOPs:

  • Compile time polymorphism
  • Run time polymorphism

i. Compile time polymorphism: It means that an object is bound to its function call at the compile time. So, it is also called early binding static binding or static linking.

ii. Run-time Polymorphism: It means that an object is bound to its function call at the run time. It defers the linking of a function call to a particular class at run-time. So it is called late binding or Dynamic binding or Dynamic linking.

7. Message Passing:

An object-oriented program consists of a set of objects that communicate with each other. Objects communicate with one another by sending and receiving information much the same way as people pass messages to one another, this concept is called message passing. A message for an object is a request for execution of a procedure and there will invoke a function in the receiving object that generates the desired result.

8. Association:

The association represents a relationship between two or more objects. It can be one-to-one, one-to-many, or many-to-many. Objects can interact with each other through their methods.

Leave a Reply

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