OOPS_Python
OOPS_Python
What is OOPs
●
OOPs (Object-Oriented Programming System) is a programming
paradigm that organizes code using objects, which are instances of
classes. It is designed to improve modularity, reusability, and
maintainability of code.
Class
A class is like a blueprint or template for creating objects. It defines
attributes (variables) and methods (functions) that the created objects
will have.
Object:
●
An object is an instance of a class. It has its own data and can use the
methods defined in the class.
Inheritance
Inheritance is an OOP principle where a child (derived) class
inherits attributes and methods from a parent (base) class.
This promotes code reuse, logical hierarchy, and reduces
redundancy.
Single Inheritance
●
One child inherits from one parent.
Multiple Inheritance
●
One child class inherits from more than one parent class.
●
Multilevel Inheritance
A chain of inheritance — child inherits from parent, and another child inherits from that child.
●
Hierarchical Inheritance
Multiple child classes inherit from the same parent class.
●
Hybrid Inheritance
A combination of multiple types (e.g., multiple + multilevel).
Polymorphism
●
It's is a core concept of object-oriented programming (OOP) that allows
objects of different classes to be treated as if they were objects of the
same class, typically through a common interface or method name.
●
In simple term, Polymorphism means "many forms" the same function
or method name behaves differently depending on the object that calls
it.