What is a dependency relationship between classes, and how does it differ from an association?

Last updated 5 July 2026

  • Dependency ("uses-a") is weak and transient: class B appears only as a parameter, local variable, or return type of A. UML shows a dashed arrow.

  • Association ("has-a") is structural: A stores a reference to B (usually a field) that persists and has multiplicity. UML shows a solid line.

  • Rule of thumb: if the link vanishes when the method returns, it is a dependency. If it is stored, it is an association.

  • https://dev.to/coderatul/self-class-diagram--7ko
All Object-Oriented Programming interview questions