Static Members of a Class in Object-Oriented Programming in Hindi – Definition, Uses, and Examples
Static Members of a Class क्या हैं?
Object-Oriented Programming (OOP) में Static Members वे Attributes और Methods होते हैं, जो Class Level पर Define किए जाते हैं और Object के बजाय Class के लिए Shared रहते हैं। इन्हें Class Variables और Class Methods भी कहा जाता है। Static Members को Access करने के लिए Class का उपयोग किया जाता है, न कि किसी Specific Object का।
Static Members की परिभाषा (Definition of Static Members)
Static Members Class का हिस्सा होते हैं और वे सभी Objects के बीच Shared होते हैं। इन्हें static Keyword के साथ Declare किया जाता है। Static Members को बिना Object बनाए भी Access किया जा सकता है।
Types of Static Members
Static Members दो प्रकार के होते हैं:- Static Variables: Class-Level Variables जो सभी Objects में समान रहती हैं।
- Static Methods: Methods जो Class-Level पर कार्य करती हैं और केवल Static Variables को Access कर सकती हैं।
Example of Static Members in Python:
class Student:
school_name = "ABC School" # Static Variable
@staticmethod
def get_school_name():
return Student.school_name # Accessing Static Variable inside Static Method
# Access Static Variable and Method without creating an Object
print(Student.school_name) # Output: ABC School
print(Student.get_school_name()) # Output: ABC School
Static Variables (Class Variables)
- Class के सभी Objects में समान रहती हैं।
- Static Variables को Class के नाम से Access किया जा सकता है।
- Memory में केवल एक बार Allocate होती हैं।
Static Methods
- Static Methods को Class Level पर Define किया जाता है।
- यह केवल Static Variables को Access कर सकते हैं।
- Python में Static Methods को
@staticmethod
Decorator का उपयोग करके Define किया जाता है।
Applications of Static Members
Static Members का उपयोग विभिन्न क्षेत्रों में किया जाता है:- Shared Resources: Static Variables का उपयोग Shared Resources को Track करने के लिए किया जाता है।
- Utility Functions: Static Methods को Helper या Utility Functions के रूप में उपयोग किया जा सकता है।
- Configuration Settings: Static Variables को Global Configuration Settings के रूप में Define किया जा सकता है।
Advantages of Static Members
Static Members के कई फायदे हैं:
- Memory Utilization में सुधार।
- Global Access की सुविधा।
- Utility Methods को Define करना आसान।
Conclusion
Static Members Object-Oriented Programming का एक महत्वपूर्ण हिस्सा हैं। Static Variables सभी Objects में Shared रहती हैं, जबकि Static Methods को Class Level पर उपयोग किया जाता है। इनकी समझ Software Design में बेहतर Memory Utilization और Efficiency प्रदान करती है।
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