UML Class Diagrams
In this article we will learn about using Class Diagrams used in UML. The Class diagrams describes the structure of the system, these structures refers to the types of objects used in the system along with the relationships. Class diagrams are designed on basis if classes getting used in the System.
Class diagrams are composed of three parts:
- Name – Defines the name of the class
- Attributes – Defines the Instance variables and Class level variables used inside class
- Methods/Operations – Defines the Functions and Methods defined inside the class
Class Diagram Layout:

Class Diagram in UML
We all know that in Object Oriented we use access specifiers to control the attributes and methods visibility, we can specify the access specifiers in Class diagrams as well.
| Specifier | Symbol |
| public | + |
| private | - |
| protected | # |
Class Diagram Example:
Suppose we have an employee object having all accessors and mutator method along with the attributes.
class employee { private int id=0; private String name=null; public int getId() { return this.id; } public void setId(int i) { this.id = i; } public int getId() { return this.id; } public void setName(String name) { this.name = name; } }
Now to represent the employee class in UML we create an Class Diagram for the Employee Class.

Class Diagram in UML
So if you the class diagram for the above example we have added two attributes and four Methods for the employee class in UML Class Diagram. Also the attributes being private we have added “-” to the id and name attribute, Similarly all the methods defined are public so we have added “+” to the getId(), setId(), setName() and getName() methods.
Class Relationships:
This represents diagrammatic view of the relationship between multiple class. For more information on the relationship between multiple class check out Introduction to Class Relationship in UML.


































