Association/Aggregation/Composition/Generalization simple example

Association

Relationship between two objects (one to one, one to many, many to many etc)

Aggregation

Aggregation is a kind of association, which refers Has a relationships.

Example: Building has a room

 Composition

It is a kind of Aggregation but when an object contains another object the contained object cannot exists without the container object
Example: Room cannot exist without building

Generalization

Generalization refers to Is a relation ship (Inheritance)
Example, Car is a Vehicle, Bus is a Vehicle

 

No comments:

Post a Comment

12 classic String-based Java interview questions with simple explanations and code.

  1️⃣ Check if a String is a Palindrome Problem Given a string, check if it reads the same forward and backward. Example: "madam...

Featured Posts