Submit Your Site To The Web's Top 50 Search Engines for Free! Java Tutorial: Learn Java Basics For Free | Learn Java

Saturday, December 14, 2019

HAS-A relationship in Java - Learn java

HAS-A relationship in Java - Learn java

1.HAS-A Relationship is also knows as composition(or) aggregation.
2.There is no specific keyword to implement HAS-A relationship but mostly 
    we can use new operator.
3.The main advantage of  reusability.

Example:-

class Engine
{
 // engine functionality
}
class Car
{
   Engine e=new Engine();
  //------------------------------;
  //------------------------------;
  //------------------------------;
}

NOTE:-

class car has-a engine reference.
The main dis-advantage of has-a relationship increases dependency between the
components and creates maintains problems.


Learn Java online free and learn java programming this is the
best way to learn java. this is best java tutorial.in this tutorial          
all the programs start with hello java,hello world.Enterprise applications         
programming language

No comments:

Post a Comment

Java multithreading Tutorial with Real-Life-Example(2025)

  Java Multithreading Tutorial with Real-Life Examples (2025) Meta Description: Learn Java Multithreading with real-world examples. Und...