-1

Assume that we have a java class Employer:

public class Employer{
     public Employer(){
        Gardener gardener = new Gardener();
        gardener.garden();
     }
}

and another class Gardener:

public class Gardener{
     public void garden(){
        System.out.println("gardening");
     }
}

What is the relationship type between Employer and Gardener in this case (Dependency or Association)?

Thanks in advance

1 Answers1

1

In general, you use an association to represent something like a field in a class. On the other hand, naming a parameter type and creating an object in a temporary variable imply a dependency.

This is case is a dependency.

For more info read this.

Sebastian D'Agostino
  • 1,575
  • 2
  • 27
  • 44