Type Here to Get Search Results !

Has-A relationship क्या होता है java में? what is Has-A relationship in java?

0

Has-A relationship क्या होता है java में? what is Has-A relationship in java?


has-a relationship को composition and aggregation भी कहा जाता है.
इसका कोई specific keyword नही है implement करने केलिए, mostly हमलोग new operator का us करते हैं.
इसका जो main advantage यह है की इससे reusability बढ़ता है.

example-
class Engine{}
class Car{
Engine e=new Engine();
}

तो अभी हम कहे सकते हैं Car HAS-A engine reference .
इसका जो main disadvantage है वोह है यह dependency बढ़ा देता है दोनों class के अन्दर या components के अंदर .

Composition क्या है java में -

container object के अलाबा contained object रहेना मुस्किल है , तो यह जो relation है conatiner object and contained object के अन्दर strong है इसीलिए इसे  composition कहेते हैं ..
example के तर पर देखिये यदि एक unversity में कुछ department है ,यदि university नही रहेगा तो department  में भी नही रहेगा इसे composition कहेते हैं .इनका जो relation है वोह बहुत ही strong है .

Aggregation क्या है java में -


हम composition में देखा की उसमे conatiner object and contained object बहुत ही strong relation है लिकिन इसमें उसका उल्टा इसमें conatiner object and contained object इसमें weakly associated .
container object अलाबा contained object रहे सकता है ,इनका relation बहुत ही weak है .इसे Aggregation कहेते हैं .

example-
example के तर पर देख सकते हैं की university में बहुत सारा professor रहेते हैं यदि कुछ डिपार्टमेंट बंद होगया तो professor दूसरा department में भी काम  कर सकते हैं .

Method signature in java -
java में method signature में method का नाम और उसका argument type होता है .एक example देता हूँ आप समझ जायेंगे –
public void methodOne(int I,float f) ;इसमें से methodOne(int,float); को कहेते हैं .और एक बात एक क्लास में एक ही नाम का एक मेथड रहे सकता है .

Post a Comment

0 Comments

Recent-post