Objects and Classes - Types - Enumerations
11 important questions on Objects and Classes - Types - Enumerations
In Fig. 6.5, we show some sample enumerations.
Can you find them?
A common enumeration, that of TrafficLightColor is shown in both a US and UK style.
UML uses the VisibilityKind to identify the visibility of attributes and operations.
The EbookKind is a useful library domain enumeration for electronic books.
The standard name for the compartment showing the enumeration literals is “literals.”
What is the note attached to the VisibilityKind?
In a class diagram, a member, i.e., an attribute or operation, would be preceded by one of the listed symbols to indicate the visibility
What is the VisibilityKind : Public +
The member value/behavior may be seen or invoked by anyone
- Higher grades + faster learning
- Never study anything twice
- 100% sure, 100% understanding
What is the VisibilityKind : Private -
What is the VisibilityKind : Protected #
Private, but instances of specializations of the class can also access
What is the VisibilityKind : Package ~
What is the VisibilityKind indicator?
In the UML specification, all the enumeration type names end with “Kind,” such as shown with VisibilityKind in Fig. 6.5.
We followed that reasonable convention with our own enumerations, but you may follow your own approach if you want.
In the figure, we included both TrafficLightColorKind and TrafficLightColourKind, to support both US and UK style traffic signals.
Enumeration literals have identity only within the...?
Enumeration literals have identity only within the enumeration.
How can you test equality between two values?
If you wish to refer to each color independently, you use the “.” naming scope operator, as shown below.
Enumerations can participate in generalizations.
Examine Fig. 6.6. How many literals does the
DirectionalTrafficLightColor have?
![]()
What is the internal representation of enumeration literals?
They could be strings, integers starting with one, or integers starting with zero, or something else.
Some tools may allow you to specify values or an order to the literals for code generation, but that is not part of current UML.
The question on the page originate from the summary of the following study material:
- A unique study and practice tool
- Never study anything twice again
- Get the grades you hope for
- 100% sure, 100% understanding
![Trustpilot Logo](/images/design_2020/lp/clp-trustpilot-en.png)