Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

wht does association, aggregation relationship between class mean in java?

likewise inheritance... other relationship are associated between class in java!!!!! my quest. is consider class A has a association/aggregation relationship with another class B.

does it mean tht class A access all method and attribute of class B?

Plz expalin me!

Update:

on theoery...i understood...while implementing,,,,,,can a class access attribute and method of the associaed class ?

3 Answers

Relevance
  • ?
    Lv 7
    1 decade ago
    Favorite Answer

    Technically an "association" is any relationship between two object classes. However, most people use "association" to really mean a dependency on one class to another.

    So, given that second definition, Association = "Needs a"

    A "Car" needs a "Driver" and a "Driver" needs a "Car"

    A "Bird" needs a "Cage"

    A "Clock" needs a "Wall" to hang on.

    Aggregation and Composition are classes that make up part of another class. Aggregration = "Has a". Composition = "is made up of a"

    Aggregation:

    A "Class" has a "Instructor" and "Student"s

    A "Box" has a "Christmas Present"

    A "Bedroom" has a "Bed"

    Composition:

    A "Car" is made up of a "Steering wheel", "Tire" (4 of them), "Seat" (2 or more)

    A "Bird" is made up of a "Beak" and "Feathers"

    A "Clock" is made up of a "Minute Hand" and a "Hour Hand"

    An "Airplane" is made up of a "Wing" (2 of them)

    (NOTE: The difference between composition and simple aggregation is if the "has a" can exist outside of its aggregation. Example: a "Beak" isn't really useful unless it is part of a "Bird". That's composition. However, a "Christmas Present" is very useful outside of the box and a student is useful outside of a classroom. That's simple aggregation.)

    Inheritance is a class that is a special kind of its superclass. Inheritance = "Is a" or "is a specific kind of"

    A "Car" is a specific kind of "Vehicle"

    A "Bird" is a specific kind of "Animal"

    A "Clock" is a specific kind of "Timekeeper"

  • Anonymous
    1 decade ago

    Yes class A can excess methods and variables of class B but only public and protected members or methods can be accessed except private because private members can only be used within their class only. In this case class A will be called as inherited or sub-class which can access all the public members of its Super class i.e. B. Inheritance can be done between two or more classes. we can inherit one class from other by using keyword "extends" ex:-

    class A extends class B {

    }

  • Anonymous
    5 years ago

    well you see there are three types of classes in java theres high quailty coffee medium quialty low quialty at the very bottom is the untochables and u cant touch them because theyir to hot and dont taste good

Still have questions? Get your answers by asking now.