HAS-A relationship

As compared to an IS-A relationship, a HAS-A relationship is easy to identify and implement. I hope this statement relieves you! Consider this definition of the bare-bones class Engine:

Of all the preceding classes—Statistics, Car, PartsFactory, and TestCar—only Car shares a HAS-A relationship with the class Engine because Car defines an instance variable of type Engine. Note that it doesn’t matter whether the instance variable engine in class Car is initialized with an object. The HAS-A relationship is shared by the classes.

Case Study 1:

Employee and Department :

Last updated

Was this helpful?