There are 4 relationship types between classes which are;

1.Composition (has a)

2.Aggregation (holds a)


4.Inheritance(is a)

We have always just one of above types in a class.


1.Composition (has a)

Person class’s life cycle is related to IdentityCard so whenever Person is created  IdentityCard will be created automatically. In composition, the reference that is containing reference can’ t be used from another reference because of being class’s local variable.

As a result, Person has a IdentityCard.

has a composition

2. Aggregation (holds a)

According to aggregation relation type any class related to containing class and the reference of containing class would be in using another reference. The difference of composition and aggregation types is containing reference whether in using to another reference out of classes.

Instance of university and student, any student can leave first of his university and same student will register for master degree to another university.

holds a aggregation student

holds a aggregation



In association type classes life cycle is independent each other but any time needs to class for specify working. The needing is not full of life cycle so there is no integrated approach in contained class.

For instance;

The relation between human and shopping centre is association because of the life cycles of classes doesn’t compulsory of each other. At any time, a human can do shopping and also any people doing shopping in shopping center.



4.Interitance (is a)

It is posible that a class can be derived from another by inherit. Sub class can be derived from super class so sub class means is a super class because of sub class inherited super class and can be extendable after than.

extends keyword is using for inherit a class. There is a hierarchy in inheritance relational type and all top of is Object class, so every class derived from Object class in Java thought compiler doesn’t say to us.