DEV Community

222010301042manas
222010301042manas

Posted on

Types of OOPs concepts in python

What is oops concept?

An object-oriented paradigm is to design the program using classes and objects. The object is related to real-word entities such as book, house, pencil, etc. The oops concept focuses on writing the reusable code. It is a widespread technique to solve the problem by creating objects.

Types of oops concept:

-Class.
-Object.
-Method.
-Inheritance.
-Polymorphism.
-Data Abstraction.
-Encapsulation.

Class:

The class inheritance mechanism allows multiple base classes, a derived class can override any methods of its base class or classes, and a method can call the method of a base class with the same name.

Object:

The object is an entity that has a state and behavior associated with it.It may be any real-world object.

Inheritance

Inheritance is a powerful feature in object oriented programming. It refers to defining a new class with little or no modification to an existing class.The new class is called derived (or child) class and the one from which it inherits is called the base (or parent) class.

Method

A method is a function that “belongs to” an object.(In Python, the term method is not unique to class instances: other object types can have methods as well.

Polymorphism

In Python, Polymorphism lets us define methods in the child class that have the same name as the methods in the parent class.In inheritance, the child class inherits the methods from the parent class.This process of re-implementing a method in the child class is known as Method Overriding.

Data Abstraction

Abstraction in OOP is a process of hiding the real implementation of the method by only showing a method signature. In Python, we can achieve abstraction using ABC (abstraction class) or abstract method. ABC is a class from the abc module in Python

Encapsulation

Encapsulation is one of the fundamental concepts in object-oriented programming (OOP).It describes the idea of wrapping data and the methods that work on data within one unit. This puts restrictions on accessing variables and methods directly and can prevent the accidental modification of data.

Top comments (0)