Uml Exercises
Uml Exercises
Paolo Ciancarini
Summary
This is a set of exercises on writing and understanding the UML notations Some exercises have more than one correct answer Most of them are taken from the net
Diagrams covered
Use case diagrams Class diagrams Object diagrams State diagrams Activity diagrams Sequence diagrams Communication diagrams
On requirements
Which of these are functional requirements?
a)Users of the library are either normal or staff b)A user can borrow a book c) A staff person can borrow a book d)The library contains one million books e)If a user asks a book that has been borrowed, her request is inserted in a waiting list f) Staff has no priority in borrowing books
On requirements
Which of these are non-functional requirements?
a)Pressing the switch the room gets lightened b)Pressing the switch the room gets lightened in less than one second c) If the room is dark, pressing the switch it gets lightened d)The light in the room must be sufficient to read e)If someone is reading then the light must stay on f) After two minutes that the room is empty the light must switch off
On requirements
Which of these are functional requirements?
a)A person can enroll in a course b)Only 10 persons max can enroll to this course c) A student is a person d)A course is taught by a professor e)A professor is not a student f) Each course terminates with an exam g)Every exam produces a ranking of all participants
On requirements
Which of these are functional requirements?
The Iphone a) can function as a camera b) has a camera with 2.0 megapixels with geotagging c) is a portable media player d) offers an Internet client e) renders a virtual keyboard by its multitouch screen f) is connected to a PC via a USB plug g) includes a digital compass in the 3GS model
On requirements
Based on the following statements from a domain expert on a project, which of the following are requirements that must be extracted? "We get incomplete mortgage applications all the time. In those cases, we just hand them back to the customer with a handwritten note telling them what's missing. We have to log the application anyway, so we use the new mortgage screen to enter the customer information and assign a unique identifier to the file. In the past, we have entered the address in upper case. The identifier follows an industry standard format of bank number, customer account number, and the next available number for that customer all as one long number."
a) b) c) d)
A note must be sent to the customer for incomplete mortgage applications, listing the missing items A file must be established for every mortgage application at the time it is submitted, whether the application is complete or not Addresses on mortgage applications must be entered as all capital letters A unique mortgage number must be assigned to each mortgage file. This identifier must follow financial industry standard format
On requirements
Which requirement has the best form?
The system could be used to manage one or more libraries The system shall manage the lending of books The system is initially either off or on The system could have several users The system goal should be to let users to borrow books
log
<<include>>
borrow lend c)
<<extend>>
log
<<extend>>
Shi p Product
Packaging Clerk
Reading exercises
Read the UML class diagram Pay attention to the multiplicity Try to understand the relationship and describe it in natural language
Veterinary System
Try to read & understand this UML diagram
Veterinary System
Read and understand this UML diagram
1 or more Pets associated with 1 PetOwner Each pet has exactly one PetOwner
Computer System
Computer System
1 CPU associated with 0 or more Controllers 1-4 DiskDrives associated with 1 SCSIController SCSIController is a (specialized) Controller
Library System
Library System
1 or more Book associated with 1 or more Pages Patron & Shelf use (depend on) Books
Banking System
Banking System
1 Bank associated with 0 or more Accounts Each Account is associated with exactly one bank Checking, Savings, and MoneyMarket are Accounts
Room has 1 Thermostat Each Thermostat is associated with 0 or more Heaters A Heather has exactly one Thermostat ElectricHeater is a specialized Heater AubeTH101D is a specialized Thermostat
Company
Each employee works for one company (which can have 0 employees) Each AdministrativeAssistant has one or more supervisors (who can have 0 or more employees) Each Company has exactly one BoardOfDirectors (and viceversa) Each Office is allocated to zero or more Employees (an Employee can have no office or at most one) A Person is boardMember of 0 or more BoardOfDirectors (each BoardOfDirectors has from 3 to 8 Persons)
Printing System
Family
On class diagrams
A house may have any number of pets living in it The two possible types of pets that can live in a house are dogs and cats Each dog or cat has a name An animals house is its one and only home You can ell an animal to make noise and it will do its thing
Solution
On class diagrams
Husband
is married to
0..n 0..n
Wife
Given that having multiple spouses at the same time is prohibited, but it is allowed to have many spouses over time a) The diagram represents the concepts to be modeled and no changes are required b) Use the <<history>> stereotype to show the history over time and snapshot in time constraint in the model. c) Promote the is married to association to an association class called Marriage and break up the Many-to-Many association between Husband and Wife d) Create a link attribute called wedding date and attach it to the association, rather than to either Class in the Association e) Create a link attribute called wedding date and attach it to either husband or wife class
On class diagrams
Person
employer
* 0..1
Company
Employment
Period
Which sentences are coherent with this model? a) A company may employ 0 or 1 person b) A person may work for a single company c) A person has one employment d) A company has one employer that is a person e) A company may have zero employers
On class diagrams
This diagram says that objects: a)Persons have a name b)Guitarists have a name c)Guitars have a name d)MusicPlayers have a name
On class diagrams
This diagram describes a) a sequence b) a domain c) a system d) a use case e) a temporal behavior
On class diagrams
Which of the following aspects is not part of a design class diagram? a)Attributes with their types b)Operations with arguments and results c)Composition relationship d)Events and actions e)Visibility information f)Navigation information
On class diagrams
Classify the following into generalization (G), association (A), aggregation (AG), or composition (C): a) A country has a capital city b) A dining philosopher uses a fork c) A file is an ordinary file or a directory file d) Files contain records e) A class can have several attributes f) A relation can be association or generalization g) A polygon is composed of an ordered set of points h) A person uses a computer language on a project
On class diagrams
The arrow between the two classes indicates: a)Inheritance b)Association c) Dependency d)Sending a message
On class diagrams
On class diagrams
On class diagrams
A visitor register is made of visitor entries
On class diagrams
This diagram says that objects having a main method are a)Persons b)Guitarists c)Guitars d)MusicPlayers, when implemented by Guitarists
On class diagrams:
Right or wrong?
Student - passedModules: list of Strings Module -name:String -code:int
On class diagrams
Right or wrong?
+ equivalents *
prerequisites
On class diagrams
Examine these two diagrams; true or false? a) The right diagram has more information b) The left diagram has more information c) They are equivalent, but the right one is simpler d) They are equivalent, but the left one is simpler
On class diagrams
On class diagrams
Which of the following are illegal combinations of subtypes in the diagram? a) Female, Patient, Nurse b) Male, Physiotherapist c) Female, Patient d) Female, Doctor, Surgeon e) Patient, Doctor f) Male, Doctor, Nurse
On class diagrams
A benefit of using polymorphism is a reduction of: a)methods in the associated classes b)subclasses needed to accomplish the same functionality c)case statements and conditionals d)coupling between classes in the system
On class diagrams
Which sentences are true? a) CheckingAccount implements BankAccount b) CheckingAccount and SavingAccount are BankAccount c) CheckingAccount and SavingAccount are associated d) BankAccount is associated to CheckingAccount e) SavingAccount can processCheck f) CheckingAccount has a balance
On object diagrams
This object diagram is instance of which class diagram(s)?
Car Wheel
Engine
Car Wheel
Engine
On object diagrams
This object diagram a)Includes an anonymous object b)Includes a class c) Includes four instances d)Includes three instances
On object diagrams
Which diagrams are correct?
Person Person Person Person
:John a)
Man b)
:John c)
Man d)
On objects diagrams
Which one is a non valid instance of this model?
a)
b)
c) d)
On object diagrams
Which is the class diagram which best corresponds to this object diagram?
Teacher
team
Teacher
assgnlab handinlab
Student
assgnlab handinlab
Student
team2 team1
a)
team2
c)
Teacher
assgnlab handinlab
Student
team1
Teacher
assgnlab handinlab
Student
b)
d)
On state diagrams
This state diagram a)Has a superstate student b)Has a superstate undergraduate c) Has several final states d)Has several initial states e)Describes two objects: student and undergraduate
On state diagrams
Describe at least three sequences of events which would get stuck this state diagram after 3 transitions
On state diagrams
The diagram represents a)A Document b)A Printer c) A Word-processor d)A User of a word-processor e)A Page being printed f) The diagram is invalid
On state diagrams
What is a guard condition in a state diagram? a)An expression comparing the attributes of the modeled objects against the attributes of the associated object. b)The condition of a person guarding the state diagram from unwitting destruction by the collaborating designers c) A boolean expression of attribute values which allows state transition only if condition is true d)A boolean expression that allows the transition from the state of the current object into a state of another object in the system e)A state activity that protects object attributes from accidental modification by unconditional actions of state transitions
On state diagrams
In a State Diagram, which of the following is true? a) Actions are associated with a transition and are considered to be processes that occur quickly and are not interruptible b) Actions are associated with transition and are considered to be processes that occur quickly and are interruptible c) Activities are associated with states and can take longer. An activity may be interrupted by some event d) Activities are associated with transition that occur quickly and are not interruptible e) Activities are associated with states and can take longer. An activity cannot be interrupted by any event
On state diagrams
In this diagram a) There are no loops b) There are five states c) Dispatching comes after Checking d) Waiting is parallel to Delivered e) There are no events f) There are simultaneous events
On state diagrams
Wait
entry/ Display search page
Display no matches
entry/ Display NoMatch msg
Display results
entry/ Display journal list
On state diagrams
Which of the following statements about state diagrams is correct? a)All actions in a state diagram are attached to transitions b)An event may cause an object to remain in the same state it was prior to the event c) Once an object leaves a state, it cannot return to that state d)Two different transitions out of the same state may overlap (they can be triggered by the same event)
On state diagrams
What state(s) is the object in after the following sequence of events? a b c b g a
On activity diagrams
Which of the following modeling elements are not found in an Activity Diagram? a)associations b)swimlanes c)initial node, final node d)fork and join nodes
On activity diagrams
What is the maximum number of concurrent threads that is possible in this activity diagram? a) 1 b) 2 c) 3 d) 4 e) 5
On activity diagrams
In this diagram: a) Fill Order is executed before Receive Payment b) Overnight Delivery is executed in parallel with Regular Delivery c) Close Order is executed after Receive Payment d) Fill Order is executed in parallel with Send Invoice e) Send Invoice is possibly executed f) Regular Delivery is always executed
On sequence diagrams
Which symbol represents a process activation? a)1 1
b)2 2
c)3
On sequence diagrams
Which one of the following fragments of sequence diagram represents the action: "Object A sends to object B several messages named msg? a) b) c) d)
On sequence diagrams
Which symbol represents a synchronous message? a)1 b)2 c) 3
1
2
3
On sequence diagrams
What is this in the red oval? a) A message b) A guard c) An event d) An association
On sequence diagrams
Given the sequence diagram on right, which class diagram is consistent?
On sequence diagrams
Given the sequence diagram on right, which class diagram is consistent?
On sequence diagrams
What can you say about the control flow of each of the following systems?
Which is more centralized? Which is more distributed?
79
On sequence diagrams
What is wrong with this sequence diagram?
80
On sequence diagrams
What is wrong with this sequence diagram?
81
On sequence diagrams
What are the names of missing classes XXX and YYY in the sequence diagram? a) XXX = DeliverySchedule, YYY = Supplier b) XXX = Supplier, YYY = DeliverySchedule c) XXX = PreferredSupplier, YYY = DeliverySchedule d) XXX = DeliverySchedule, YYY = PreferredSupplier
On communication diagrams
This diagram contains a)swimlanes and temporal marks b)objects and messages c) classes and associations d)components and events
On communication diagrams
These two diagrams are equivalent or not?
On diagrams
Which among these are behavior diagrams? a)Use case diagrams b)Class diagrams c)State diagrams d)Sequence diagrams e)Communication diagrams f) Package diagrams g)Deployment diagrams
On diagrams
For understanding event control mechanisms, such as user interfaces and device controllers, which one of the following artifacts is the most useful? a)Interaction Diagrams b)Activity Diagrams c) Package Diagrams d)State Diagrams e)Class Diagrams f) Communication diagrams g)Deployment diagrams
On diagrams
What is the best diagram type to represent the sentence all men are mortal? a) Use case diagram Mortal
b) Class diagram Man
c) Object diagram d) Activity diagram e) Communication diagram
On diagrams
For the business modeling of a human organization or the workflow of a system, which one of the following artifacts is the most useful? a)Interaction Diagrams b)Activity Diagrams c) Package Diagrams d)State Diagrams e)Class Diagrams f) Collaboration diagrams
On diagrams
What are the nodes in this diagram? a)Roles b)Actors c)Use cases d)Artifacts e)Events
On diagrams
A car has a Starter, some Lights, an AirConditioning System, some Wheels. The driver operates first the Starter, then the Lights, then the AirConditioning System, and finally the Wheels. Which pair of diagrams is most useful to model this situation? a) Use cases and scenarios b) Use cases and class diagrams c) Class and sequence diagrams d) Class and statechart diagrams e) Class and object diagrams
Do-it-yourself exercises
Use case diagram describe how to play chess via an interface able to connect either different engines or a chess server via internet Class diagram describe the pieces, chessboard and the game tree Object diagram describe by object snapshots a chess position during a game Activity diagram describe a game workflow including two players playing via a (telnet) chess server Statechart describe a game workflow from the viewpoint of the chessboard Sequence diagram describe a multiagent system evaluating a position Communication diagram describe a multiagent system evaluating a position
References
www.pearsonvue.com/omg/! www.objectsbydesign.com/projects/umltest/bparanj-answers-1.html! dn.codegear.com/article/31863! parlezuml.com! www.proprofs.com/quiz-school/story.php?title=quiz-uml-20!