Website/App design एवं college projects आदि के लिए संपर्क करें – 8085589371

Introduction to OOPs

OOPs का फुल फॉर्म है Object-Oriented Programming System, यह एक प्रकार है प्रोग्राम लिखने का, जिसमे Objects and Classes उपयोग किया जाता है, जो इस प्रकार से Program लिखने के तरीके का उपयोग करते है उसे Object-Oriented Programming कहते है।

Object-Oriented Programming में कुछ महत्वपूर्ण concepts है जिनको OOPs concept कहा जाता है जिनको सीख लेने के बाद हम Object-Oriented Programming में कोड लिख पाएंगे। OOPs के निम्नलिखित है –

Features of OOPs (Pillars of OOps)

  • Class
  • Object
  • Encapsulation
  • Abstraction
  • Polymorphism
  • Inheritance

Class

Class एक user-defined डाटा टाइप है या Class एक blue-print है किसी ऑब्जेक्ट का। Class के अंदर variable, constant एवं methods (ये function ही है, Class के अंदर है इसलिए इन्हे method कहा जाता है) आदि define रहते है जिन्हे Class के members कहा जाता है।

  • Class का feature हर एक High Level Programming Language में होता है
  • Class के static members को केवल Class की ही मदद एक्सेस कर किया जा सकता है
  • एक Class बनने के लिए “class” keyword का उपयोग किया जाता है
  • Class के abstract डाटा टाइप भी है।

Object

Object एक रियल वर्ल्ड एंटिटी है जो वास्तव में कंप्यूटर मेमोरी exists करती है, एक Class चाहे कितने भी Object बनाये जा सकते है। Object की properties हि Object के attributes कहलाते है।

उदहारण के लिए student, laptop आदि ऑब्जेक्ट है।

Explanation

जब भी हम कोई मकान, सड़क या मशीन आदि बनाते है तो बनाने से पहले एक संरचना (structure) बनाते है जिसे नक्शा या ब्लू-प्रिंट कहते है (ऐसी ब्लू-प्रिंट को Programming world में class कहते है) नक्शा बनाने के बाद मकान, सड़क या मशीन आदि कुछ रियल में जो बनाया है वह Object है।

  • Class के non-static members को केवल Class का Object ही एक्सेस कर सकता है।

Example – Class & Object

Encapsulation

डेटा (attributes) तथा फंक्शन (methods) को एक ही यूनिट में सम्मिलित करना Encapsulation कहलाता है। encapsulation को Class के मदद से achieve किया जा सकता है encapsulation की मदद से class members को direct से protect किया जाता है, ताकि क्लास डाटा एवं functions का गलत उपयोग न हो

  • Encapsulation को प्राप्त करने के लिए class के members को प्राइवेट रखा जाता है एवं इनकी value set या get करने के लिए getters (value को प्राप्त के लिए) एवं setters (value को के लिए) methods का उपयोग किया जाता है।

Example

Abstraction

Abstraction के महत्वपूर्ण OOPs concept है जिसमे Object की केवल user से अनावश्यक जानकारी छुपाना है अर्थात यूजर को केवल वही जानकारी दिखाना जो जरुरी है इसमें जो implementation की जानकारी छुपाना जाता है |

  • जैसे हम कोई सॉफ्टवेयर उपयोह करते तो हमें सिर्फ features दिखाई देते है जिन्हे हमें उपयोग है लेकिन  implementation  की जानकारी नहीं दी जाती है की यह कैसे work कर रहा है, तो हम सकते है की implementation  या internal को hide करना ही abstraction है |

Polymorphism

Polymorphism दो शब्दों से मिलकर बना हुआ है Poly (अर्थात अधिक [many] ) एवं Morphism (अर्थात फॉर्म्स) यानी many-forms (जब एक ऑब्जेक्ट, एक से अधिक फॉर्म्स में उपस्थित हो वह Polymorphism है)

Types of Polymorphism

Polymorphism निम्नलिखितदो प्रकार है-

  • Compile-Time Polymorphism
  • Run-Time Polymorphism

Polymorphism in OOPs in hindi

Compile-Time Polymorphism

जब एक ही नाम की दो method एक ही class में हो लेकिन signature (signature से आशय है implementation) डिफरेंट हो तब वह Compile-Time Polymorphism होता है। 

  • Compile-Time Polymorphism को static binding या early biding भी कहते है।

Example – Method (Function) Overloading, Operator Overloading

Run-Time Polymorphism

जब एक ही नाम की दो method हो एवं signature  भी सामान हो लेकिन  class डिफरेंट हो तब वह Run-Time Polymorphism होता है। (एक method parent क्लास में होगी दूसरी method चाइल्ड क्लास में होगी)

  • Run-Time Polymorphism को dynamic binding या late biding भी कहते है।

Inheritance

Inheritance का अर्थ है ‘विरासत’। जब एक Class किसी दूसरे Class की प्रॉपर्टीज को Inherit (प्राप्त) करना ही, Inheritance कहलाता है।

Inheritance में, जिस क्लास (main class) से दूसरी क्लास इन्हेरिट हुई है उसे चाइल्ड क्लास या sub-class कहते है और जिस क्लास ने चाइल्ड क्लास इन्हेरिट हुई है उसे पैरेंट क्लास कहते है

inheritance in OOPs in hindi

Types of Inheritance

  • Single Level Inheritance
  • Multi-Level Inheritance
  • Multiple Inheritance
  • Hierarchical Inheritance
  • Hybrid Inheritance

Advantages of OOPs

  • Object-Oriented Programming का उपयोग करने से software की security बढ़ जाती है।
  • Object-Oriented Programming के उपयोग से programs की reusability बढ़ जाती है।
  • Software के मेंटेनेंस में आसानी होती है।
  • Software में features addon करने में आसानी। 

Single Level Inheritance

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top