Static and Run-Time Polymorphism in Object-Oriented Programming in Hindi – Definition, Differences, and Examples
Static और Run-Time Polymorphism क्या हैं?
Object-Oriented Programming (OOP) में Polymorphism दो प्रकार का होता है: Static Polymorphism और Run-Time Polymorphism। दोनों का उपयोग Code को अधिक Dynamic और Reusable बनाने के लिए किया जाता है।
Static Polymorphism की परिभाषा (Definition of Static Polymorphism)
Static Polymorphism को Compile-Time Polymorphism भी कहा जाता है। यह Method Overloading और Operator Overloading के माध्यम से प्राप्त होता है। Static Polymorphism में Method का निर्णय Compile-Time पर होता है।
Example of Static Polymorphism (Method Overloading):
class MathOperations:
def add(self, a, b, c=0):
return a + b + c
math = MathOperations()
print(math.add(2, 3)) # Output: 5
print(math.add(2, 3, 4)) # Output: 9
Run-Time Polymorphism की परिभाषा (Definition of Run-Time Polymorphism)
Run-Time Polymorphism को Dynamic Polymorphism भी कहा जाता है। यह Method Overriding के माध्यम से प्राप्त होता है। Method का निर्णय Run-Time पर किया जाता है।
Example of Run-Time Polymorphism (Method Overriding):
class Animal:
def sound(self):
print("Animal makes a sound")
class Dog(Animal):
def sound(self):
print("Dog barks")
animal = Animal()
dog = Dog()
animal.sound() # Output: Animal makes a sound
dog.sound() # Output: Dog barks
Difference between Static and Run-Time Polymorphism
Feature | Static Polymorphism | Run-Time Polymorphism |
---|---|---|
Definition | Method का निर्णय Compile-Time पर होता है। | Method का निर्णय Run-Time पर होता है। |
Implementation | Method Overloading और Operator Overloading के माध्यम से। | Method Overriding के माध्यम से। |
Polymorphism Type | Compile-Time Polymorphism | Dynamic Polymorphism |
Performance | Performance बेहतर होती है क्योंकि निर्णय Compile-Time पर होता है। | Run-Time पर Method चुनने के कारण Performance थोड़ा कम होती है। |
Advantages of Static and Run-Time Polymorphism
Static Polymorphism:
- Code को अधिक Readable और Maintainable बनाता है।
- Compile-Time Errors को कम करता है।
- Performance बेहतर होती है।
Run-Time Polymorphism:
- Code को अधिक Dynamic और Flexible बनाता है।
- Parent Class के Methods को Customize करने की सुविधा।
- Extensibility को बढ़ाता है।
Applications of Static and Run-Time Polymorphism
इनका उपयोग विभिन्न क्षेत्रों में किया जाता है:
- Game Development
- Database Management Systems
- User Interface Design
- Real-Time Systems
- Simulation Systems
Conclusion
Static और Run-Time Polymorphism Object-Oriented Programming के महत्वपूर्ण हिस्से हैं। Static Polymorphism Compile-Time पर Method का निर्णय करता है, जबकि Run-Time Polymorphism Method का निर्णय Run-Time पर करता है। दोनों की समझ Software Design को अधिक Dynamic और Reusable बनाती है।
Related Post
- Introduction to Object-Oriented Thinking in Hindi – Definition, Concepts, and Examples
- Object-Oriented Programming (OOP) in Hindi – Definition, Principles, and Examples
- Difference between OOP and POP in Hindi – Object-Oriented Programming vs Procedural Programming
- Features of Object-Oriented Paradigm – Merits and Demerits of OO Methodology in Hindi
- Object Model and Elements of OOPS in Hindi – Definition, Components, and Examples
- I/O Processing in Object-Oriented Programming in Hindi – Definition, Types, and Examples
- Encapsulation and Data Abstraction in Object-Oriented Programming in Hindi – Definition, Difference, and Examples
- Concept of Objects in OOP – State, Behavior, and Identity in Hindi
- Message Passing in Object-Oriented Programming in Hindi – Definition, Process, and Examples
- Construction and Destruction of Objects in Object-Oriented Programming in Hindi – Definition, Process, and Examples
- Classes in Object-Oriented Programming in Hindi – Identifying Classes, Attributes, and Services
- Access Modifiers in Object-Oriented Programming in Hindi – Definition, Types, and Examples
- Static Members of a Class in Object-Oriented Programming in Hindi – Definition, Uses, and Examples
- Instances in Object-Oriented Programming in Hindi – Definition, Creation, and Examples
- Inheritance and Its Types in Object-Oriented Programming in Hindi – Definition, Types, and Examples
- 'is a' Relationship, Association, and Aggregation in Object-Oriented Programming in Hindi – Definition, Examples, and Uses
- Concept of Interface and Abstract Classes in Object-Oriented Programming in Hindi – Definition, Differences, and Examples
- Polymorphism in Object-Oriented Programming in Hindi – Introduction, Types, and Examples
- Method Overriding and Overloading in Object-Oriented Programming in Hindi – Definition, Differences, and Examples
- Static and Run-Time Polymorphism in Object-Oriented Programming in Hindi – Definition, Differences, and Examples
- Exception Handling in Object-Oriented Programming in Hindi – Definition, Types, and Examples
- Multithreading and Data Collection in Hindi – Definition, Uses, and Examples
- ATM System and Library Management System Case Study in Hindi – Analysis and Design