Eslam Hamdy
Eslam Hamdy

Reputation: 7386

what is the relationship between 2 classes?

If i have Class A and Class B what is the relation-ship between them if nothing else is stated (no HAS-A) relation-ship stated, is it Association?

class A{}
class B{}

Upvotes: 0

Views: 799

Answers (3)

Tito
Tito

Reputation: 9044

They are the child classes of the parent class called java.lang.Object , other than that , there is no visible relationship.

Upvotes: 5

Ashish
Ashish

Reputation: 520

Based on the information you supplied. No, there is no relationship. In java, both inherit from the java.lang.Object. But from OO perspective, there is no relationship.

Class can be related in the following ways:

Aggregation - This is a has-a relationship where Class A has at least 1 field whose type is of classB Inheritance - This is an is-a relationship where a class B is a specialization of another class A. In this kind of relationship, the classB inherits all the behaviours of the class A.

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 838216

There is no relation between those classes.

The only relationship that I can see is that they both implicitly inherit from Object.

Upvotes: 6

Related Questions