Virtual Position Forum
Please register to watch content in detail
Thanks
Admin virtual position


Join the forum, it's quick and easy

Virtual Position Forum
Please register to watch content in detail
Thanks
Admin virtual position
Virtual Position Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Association in java 2011

View previous topic View next topic Go down

GMT + 3 Hours Association in java 2011

Post by sharmila farooqi Sun May 29, 2011 5:20 pm

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.
avatar
sharmila farooqi
Monstars
Monstars

Posts : 35
Join date : 2011-05-29

Back to top Go down

GMT + 3 Hours Re: Association in java 2011

Post by Vuhelper Sun May 29, 2011 5:21 pm

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.
avatar
Vuhelper
Deep Bench
Deep Bench

Posts : 97
Join date : 2011-05-29

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum