There are 2 ways to present the ref
variable of MyClass
: You can present it as attribute or as association. Then there are two alternative notations for the Interface
interface: Square with the interface stereotype or circle. This makes 2*2=4 alternatives.
- Show
ref
as association and use square interface notation.

Here you can't show the initial value that ref
takes. That's because you can't show default values in associations.
- Show
ref
as association but use the circle notation for the Interface.

As it was with the previous alternative, again here you can't show the initial value.
- Show
ref
as attribute and use square interface notation.

Here you can show the default value, because you can do that for attributes. The relationship between MyClass
and Interface
is presented as a dependency. The same happens for the dependency between MyClass
and ConcreteClass
.
Note that this dependency (MyClass
depends on ConcreteClass
) can be presented also in the alternatives 1 and 2, you can add a dependency arrow (dashed) pointing from MyClass
to ConcreteClass
.
- Show
ref
as attribute and use circle interface notation.

Again here you can show the default value.
If we count also the alternatives derived from presenting or not the dependencies, then there are at least 6 ways to present the same thing. Now the question is which to chose.
It depends on what do you want to visualize with the diagram and for whom the diagram is intended. In this case if the initialization of ref
is the message, then you should use an alternative that presents it. If it's less important, then you might prefer a diagram that shows ref
as association.
In a real problem you have more elements, so it makes much more alternatives. It's always up to you to decide what to present and how.
EDIT: Some references to help you understand the notation of interface implementation.
According to wikipedia:
A realization is a relationship between classes, interfaces,
components, and packages that connects a client element with a
supplier element. A realization relationship between classes and
interfaces and between components and interfaces shows that the class
realizes the operations offered by the interface.
You can find some quick reference examples and a lot of information at uml-diagrams.org.
This excellent answer Explanation of the UML arrows will help you with more examples.
Here you can also find some more info on realization.