Notes

Characteristics of Object-Oriented Programming (OOP) [ English ]

< Prev Next >

1. Introduction

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of objects and classes. It focuses on organizing code into reusable and modular components.

The main characteristics (features) of OOP are:

  1. Encapsulation
  2. Abstraction
  3. Inheritance
  4. Polymorphism

These features help in building efficient, maintainable, and scalable programs.

2. Encapsulation

2.1 Definition

Encapsulation is the process of binding data (variables) and methods (functions) together into a single unit (class).

It also restricts direct access to some components, which helps in data protection.

2.2 Example

class Student:
    def __init__(self, name):
        self.name = name

    def display(self):
        print(self.name)

2.3 Key Points

3. Abstraction

3.1 Definition

Abstraction means hiding internal implementation details and showing only essential features to the user.

3.2 Example

class Car:
    def start(self):
        print("Car started")

Explanation

3.3 Key Points

4. Inheritance

4.1 Definition

Inheritance allows one class (child class) to inherit properties and methods from another class (parent class).

4.2 Example

class Animal:
    def speak(self):
        print("Animal speaks")

class Dog(Animal):
    pass

d = Dog()
d.speak()

4.3 Key Points

5. Polymorphism

5.1 Definition

Polymorphism means one function or method can have many forms.

5.2 Example

def add(a, b):
    return a + b

print(add(2, 3))
print(add("Hello ", "World"))

5.3 Key Points

6. Additional Characteristics

6.1 Modularity

6.2 Reusability

6.3 Maintainability

7. Summary

< Prev Next >