Association in java 2011
Virtual Position Forum :: Members Lounge :: Sciences & Knowledge :: Programing and Design :: Java Forum
Page 1 of 1 • Share
Association in java 2011
I have two classes named Teacher and Student. Student class will get services from Teacher class, How to Associate Teacher class with student class?. I made two Independent classes and now how to Associate?
How teacher class will refer to student class. How to establish reference in Teacher class?
and use Student object in Teacher class?
thanks.
How teacher class will refer to student class. How to establish reference in Teacher class?
and use Student object in Teacher class?
thanks.
sharmila farooqi- Monstars
- Posts : 35
Join date : 2011-05-29
Re: Association in java 2011
In Associations are typically implemented by references, i.e. object of one class will be used in the other class.
An Aggregation is an Association which denotes an "is part of" relationship. Unfortunately, the definition of this relationship is quite lax, so basically everyone is using his own interpretation. The only definitive (?) property is that in an instance graph, aggregations are not allowed to be circular - that is, an object can not be "a part of itself". (or) When building new classes from existing classes using aggregation, a composite object built from other constituent objects that are its parts. Java supports aggregation of objects by reference, since objects can't contain other objects explicitly.
A Composition adds a lifetime responsibility to Aggregation. In a garbage collected language like Java it basically means that the whole has the responsibility of preventing the garbage collector to prematurely collect the part - for example by holding a reference to it. (In a language like C++, where you need to explicitly destroy objects, Composition is a much more important concept.) Only one whole at a time can have a composition relationship to a part, but that relationship doesn't need to last for the whole lifetime of the objects - with other words, lifetime responsibility can be handed around.
An Aggregation is an Association which denotes an "is part of" relationship. Unfortunately, the definition of this relationship is quite lax, so basically everyone is using his own interpretation. The only definitive (?) property is that in an instance graph, aggregations are not allowed to be circular - that is, an object can not be "a part of itself". (or) When building new classes from existing classes using aggregation, a composite object built from other constituent objects that are its parts. Java supports aggregation of objects by reference, since objects can't contain other objects explicitly.
A Composition adds a lifetime responsibility to Aggregation. In a garbage collected language like Java it basically means that the whole has the responsibility of preventing the garbage collector to prematurely collect the part - for example by holding a reference to it. (In a language like C++, where you need to explicitly destroy objects, Composition is a much more important concept.) Only one whole at a time can have a composition relationship to a part, but that relationship doesn't need to last for the whole lifetime of the objects - with other words, lifetime responsibility can be handed around.
Vuhelper- Deep Bench
- Posts : 97
Join date : 2011-05-29
Similar topics
» New development in java 2011
» Cookie in java 2011
» DML Statements in java 2011
» what are classes in java 2011 ?
» How to set path in Java 2011
» Cookie in java 2011
» DML Statements in java 2011
» what are classes in java 2011 ?
» How to set path in Java 2011
Virtual Position Forum :: Members Lounge :: Sciences & Knowledge :: Programing and Design :: Java Forum
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Yesterday at 9:57 am by Ibad Khan Buledi
» house disrepair claims
Mon Apr 22, 2024 11:23 am by Joshuaadam
» Aloha Planner - Note-Taker
Thu Apr 11, 2024 4:52 pm by ali001
» Streaming Guide Film TV Series
Tue Apr 09, 2024 9:39 pm by ali001
» Apricot Tree Problems & Solutions ????|خوبانی کے پھل کو کیڑا لگنےسے بچانے کا طریقہ ????
Sun Apr 07, 2024 6:28 am by Zamaan Khan
» خوبانی کے پودے کی کاشت گرم علاقوں میں کرنی چاہیے یا نہی
Sun Apr 07, 2024 6:24 am by Zamaan Khan
» New Here
Sun Apr 07, 2024 6:15 am by Zamaan Khan
» Bajta Hua Sochoon Main Koi Saaz Na Aaye Naat
Sun Apr 07, 2024 6:14 am by Zamaan Khan
» Woh Pagal Si Episode 52 to 62 - Top Pakistani Drama
Sun Apr 07, 2024 6:06 am by Zamaan Khan