Exercise 1
Question
In a UML diagram, what does the symbol - preceding an attribute denote?
Show solution ↓Hide solution ↑
Solution
It denotes private visibility, indicating the member is encapsulated and inaccessible to outside callers.
The Unified Modeling Language (UML) class diagram provides a standard visual representation of classes and their interrelationships.
A standard UML class box is split into three horizontal sections:
«interface» if an interface).- balance: double).+ deposit(amount: double): void).| Symbol | Visibility | Description |
|---|---|---|
| + | Public | Accessible from any class |
| - | Private | Accessible only within the declaring class |
| # | Protected | Accessible within package and subclasses |
| ~ | Package-private | Accessible only within the same package |
Multiplicity indicates how many instances participate in a relationship:
1: Exactly one0..1: Zero or one (optional)* or 0..*: Zero or many1..*: One or moreIn a UML diagram, what does the symbol - preceding an attribute denote?
It denotes private visibility, indicating the member is encapsulated and inaccessible to outside callers.