Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Posts
    28
    Rep Power
    0

    Default How to implement aggregation relationship in java?

    What is Aggregation and generalization?How to implement aggregation?What is the difference between these two?

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,570
    Blog Entries
    7
    Rep Power
    21

    Default

    Is Google down in your part of the world?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Sheenu Gupta is offline Member
    Join Date
    Jul 2011
    Location
    Chandigarh
    Posts
    9
    Rep Power
    0

    Default

    Aggregation is a special case of association. A directional association between objects. When an object has another object, then you have got an aggregation between them. Direction between them specified which object contains the other object. Aggregation is also called a “Has-a” relationship.

    Generalization uses a “is-a” relationship from a specialization to the generalization class. Common structure and behaviour are used from the specializtion to the generalized class. At a very broader level we understand this as inheritance. We take the term inheritance is, we can relate this term very well. Generalization is also called a “Is-a” relationship.

    Example: Consider there exists a class named Person. A student is a person. A faculty is a person. Therefore here the relationship between student and person, similarly faculty and person is generalization.

  4. #4
    Sheenu Gupta is offline Member
    Join Date
    Jul 2011
    Location
    Chandigarh
    Posts
    9
    Rep Power
    0

    Default

    Lets take an example of Employee and Company.

    A single Employee can not belong to multiple Companies (legally!! ), but if we delete the Company, Employee object will not destroy.

    Here is respective Model and Code for the above example.


    Employee class has Aggregation Relationship with Company class

    Employee
    myName_p : char *
    <<constructor>> Employee()
    <<destructor>> ~ Employee()
    Disp()

    Company
    Name_p : char *
    myEmp_p : Employee
    <<constructor>> Company()
    <<destructor>> ~ Company()

Similar Threads

  1. Trouble with aggregation
    By gto400no1 in forum New To Java
    Replies: 12
    Last Post: 05-05-2010, 03:41 AM
  2. Aggregation !!
    By Sary in forum New To Java
    Replies: 13
    Last Post: 04-14-2010, 06:57 AM
  3. class relationship
    By RajShri in forum New To Java
    Replies: 2
    Last Post: 01-04-2010, 05:54 AM
  4. UML association,aggregation etc generator
    By alexander.s in forum New To Java
    Replies: 1
    Last Post: 09-18-2008, 06:27 PM
  5. inheritance and aggregation
    By java_fun2007 in forum New To Java
    Replies: 3
    Last Post: 12-13-2007, 01:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •