Has – A relation in Core Java

This “Has – A relation in Java” page explaining clearly how an object holds reference of another object and how to access object functionality using Has-A relation in Java.


Has-A relation:

  • It is the concept of “Holding object address by another Object”.
  • We can implement Has-A relation using Non-static variables.
  • Non-static variable can be an object reference variable to store address.
  • Simple Has-A relation between 2 objects can be described as follows.
    • “She  Has-A  Mobile”
  • Here ‘she’ is one object and ‘mobile’ is another object.


  • Has-A relation doesn’t depends on Is-A relation.
  • Hence Parent-Child relation no need to be implemented in Has-A relation.


Example Code:

Police ‘Has-A’ controller of Helicopter

  • Human(Object) is holding the Reference(Controller) of another Object(Helicopter).
  • Hence Human can control(access) the complete functionality of that Helicopter.


Share this