UML Interview Questions Overview
UML Interview Questions Overview
Table of Contents
(B) Define UML?
(I) Can you explain use case diagrams?
(I) Can you explain primary and secondary actors?
(I) How does a simple use case look like?
(I) Can you explain ‘Extend’ and ‘Include’ in use cases?
(I) Can you explain class diagrams?
(B) How do we represent private, public and protected in class diagrams?
(I) what does associations in a class diagram mean?
(I) Can you explain aggregation and composition in class diagrams?
(A) What are composite structure diagram and reflexive association in class diagrams?
(I) Can you explain business entity and service class?
(I) Can you explain System entity and service class?
(B) Can you explain generalization and specialization?
(B) How do we represent an abstract class and interface UML?
(B) How do we achieve generalization and specialization?
(I) Can you explain object diagrams in UML?
(I) Can you explain sequence diagrams?
Introduction
Again i repeat do not think you get an architecture position by reading interview questions. But yes there should be some kind of reference which will help you quickly
revise what are the definition. Just by reading these answers you get to a position where you are aware of the fundamentals. But if you have not really worked you will
surely fail with scenario based questions. So use this as a quick revision rather than a shot cut.
To give you a practical understanding i have put all the design patterns and UML in a video format and uploaded here. You can visit this Web site and download the
complete architecture interview questions PDF which covers SOA , UML , Design patterns , Togaf , OOPs etc.
In my previous section we had concentrated on design patterns which is one of the most important fundamentals for architecture interviews. In case you have missed it
below are the link. One of the other areas other than design patterns which needs to be stronger for architects is putting appropriate UML diagrams in design
document.
Scenario: A scenario is a sequence of events which happen when a user interacts with the system.
[Link] 1/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Actor: Actor is the who of the system, in other words the end user.
Use Case: Use case is task or the goal performed by the end user. Below figure ‘Use Case’ shows a simple scenario with ‘Actor’ and a ‘Use Case’. Scenario represents an
accountant entering accounts data in the system. As use case’s represent action performed they are normally represented by strong verbs.
Actor’s are represented by simple stick man and use case by oval shape as shown in figure ‘Use Case’ below.
Use Case
Login
Name
Description This uses depicts the flow of how user will log-in into the chat application.
Primary
Simple chat user.
Actor
Pre-condition NA
Failed End
Duplicate user name is not allowed in the chat application.
conditions
User types chat application on URL of the browser which in turn opens the main page.
In the main page of application user is popped up with ‘Enter user name’ option and various
‘rooms’ option drop down menu.
Main User then types the name and selects one of the room from drop down menu and then clicks
Scenario on the ‘Log-in’ button.
Application then checks whether the user name is unique in the system if not then user is
popped up with error message that “user already exist”.
After entering the unique name the user is finally logged in the application.
Action NA
[Link] 2/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Alternate NA
Scenario
Success
1. Opens page of a selected room in that other user names and their messages can be seen.
Scenarios
Note and
NA
Open Issues
Note: You must be wondering why we have this pair why not just a use case table only. Use case diagrams are good to show relationship between use case and they
also provide high over view. The table explanation of a use case talks details about the use case. So when a developer or a user is reading a requirement document, he
can get an overview by looking at the diagram if he is interested he can read the use case tables for more details.
Include: Include relationship represents an invocation of one use case by the other. If you think from the coding perspective its like one function been called by the
other function.
Extend: This relationship signifies that the extending use case will work exactly like the base use case only that some new steps will inserted in the extended use case.
Below figure ‘Extend and Include’ shows that ‘add customer’ is same as the ‘add discounted customer’. The ‘Add discounted customer’ has an extra process, to define
discount for the discounted customer which is not available for the simple customer. One of the requirements of the project was that when we add a customer, the
system should send an email. So after the customer is added either through ‘Add simple customer’ use case or ‘Add discounted customer’ use case it should invoke
‘send a email’ use case. So we have defined the same with a simple dotted line with <<include>> as the relationship.
Note: One of the points to be noted in the diagram ‘Extend and Include’ is we have defined inheritance relationship between simple and admin user. This also helps us
defining a technical road map regarding relationships between simple and admin user.
Class is basically a prototype which helps us create objects. Class defines the static structure of the project. A class represents family of an object. By using Class we can
create uniform objects.
In the below figure you can see how the class diagram looks. Basically there are three important sections which are numbered as shown in the below. Let’s try to
understand according to the numbering:
Class name: This is the first section or top most section of the Class which represents the name of the Class (clsCustomer).
Attributes: This is the second section or the middle section of the class which represents the properties of the system.
Methods: This section carries operation or method to act on the attributes.
Now in the next section we will have a look on Association relationship between these classes.
In the figure ‘Order is paid by payments class’, we can see Order class and the Payment class and arrowed line showing relationship that the order class is paid using
payment class in other words order class is going to be used by payment class to pay the order. The left to right marked arrow basically shows the flow that order class
uses the payment class.
In case payment class using the order class then the marked arrow should be right to left showing the direction of the flow.
Multiplicity
Multiplicity can be termed as classes having multiple associations or one class can be linked to instances of many other classes. If you look at the below figure the
customer class is basically associated with the address class and also observes the notations (*, 0 and 1).If you look at the right hand side the (1….*) notation indicates
that at least one or many instance of the address class can be present in the customer class. Now towards left hand side we have (0….*) notation indicating that address
class can exist without or many customer class can link him.
In order to represent multiplicity of classes we have to show notations like (1….*), (0….*) as shown in below figure.
Note: ‘*’ means “many” where as ‘(0, 1)’ means “(zero or at least one)” respectively.
[Link] 4/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Aggregation Association signifies that the whole object can exist without the Aggregated Object. For example in the below figure we have three classes university class,
department class and the Professor Class. The university cannot exist without department which means that university will be closed as the department is closed. In
other words lifetime of the university depend on the lifetime of department.
In the same figure we have defined second Association between the department and the Professor. In this case, if the professor leaves the department still the
department continues in other words department is not dependent on the professor this is called as Composition Association.
Note: The filled diamond represents the aggregation and the empty diamond represents the composition. You can see the figure below for more details.
(A) What are composite structure diagram and reflexive association in class diagrams?
When we try to show Aggregation and Composition in a complete project the diagram becomes very complicated so in order to keep it simple we can use Composite
structure diagram. In the below figure we have shown two diagrams one is normal diagram other is Composite structure diagram and the simplicity can easily be
identified. In the composite diagram the aggregated classes are self contained in the main class which makes it simpler to read.
[Link] 5/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Reflexive associations
In many scenarios you need to show that two instances of the same class are associated with each other and this scenario is termed as Reflexive Association. For
instance in the below figure shows Reflexive Association in the real project. Here you can see customer class has multiple address class and addresses can be a Head
office, corporate office or Regional office. One of the address objects is Head office and we have linked the address object to show Reflexive Association relationship.
This is the way we can read the diagram Regional address object is blocked by zero or one instance of Head office object.
With this approach we have separated the data from the behavior. The service represents the behavior while the business entity represents the persistent data.
The other flavor of the system service class is to operate on non-persistent information. The first flavor operated on persistent information. For instance the below figure
‘Non-persistent information’ shows how the class ‘ClsPaymentService’ class operates on the payment gateway to Check is the card exists , Is the card valid and how
much is the amount in the card ?. All these information are non-persistent. By separating the logic of non-persistent data in to a system service class we bring high
reusability in the project.
Note: The above question can be asked in interview from the perspective of how you have separated the behavior from the data. The question will normally come
twisted like ‘How did you separate the behavior from the data?’.
In Generalization and Specialization we define the parent-child relationship between the classes. In many instance you will see some of the classes have same properties
and operation these classes are called super class and later you can inherit from super class and make sub classes which have their own custom properties. In the below
figure there are three classes to show Generalization and Specialization relationship. All phone types have phone number as a generalized property but depending
upon landline or mobile you can have wired or simcard connectivity as specialized property. In this diagram the clsphone represent Generalization whereas clslandline
and clsmobile represents specialization.
[Link] 7/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Abstract classes are represented by ‘{abstract}’ as shown in figure ‘Abstract classes in action’.
The diagram also states that ‘ClsStudent’ can apply for many courses. The same is represented in object diagram by showing two objects one of the ‘Computer’ and the
other of ‘English’.
Note: Object diagrams should only be drawn to represent complicated relationship between objects. It’s possible that it can also complicate your technical document as
lot. So use it sparingly.
Sequence diagrams
[Link] 8/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Sequence diagram shows interaction between objects over a specific period time. Below figure 'Sequence diagram' shows how a sequence diagram looks like. In this
sequence diagram we have four objects 'Customer','Product','Stock' and 'Payment'. The message flow is shown vertically in waterfall manner i.e. it starts from the top
and flows to the bottom. Dashed lines represent the duration for which the object will be live. Horizontal rectangles on the dashed lines represent activation of the
object. Messages sent from a object is represented by dark arrow and dark arrow head. Return message are represented by dotted arrow. So the figure shows the
following sequence of interaction between the four objects:
Customer object sends message to the product object to request if the product is available or not.
Product object sends message to the stock object to see if the product exists in the stock.
Stock object answers saying yes or No.
Product object sends the message to the customer object.
Customer object then sends a message to the payment object to pay money.
Payment object then answers with a receipt to the customer object.
One of the points to be noted is product and stock object is not active when the payment activity occurs.
There are five different kinds of messages which can be represented by sequence.
Synchronous messages are represented by a dark arrow head while asynchronous messages are shown by a thin arrow head as shown in figure ‘Synchronous and
Asynchronous’.
Recursive message
We have scenarios where we need to represent function and subroutines which are called recursively. Recursive means the method calling himself. Recursive messages
are represented by small rectangle inside a big rectangle with an arrow going from the big rectangle to the small rectangle as shown in figure ‘Recursive message’.
[Link] 9/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Message iteration
Message iteration represents loops during sequences of activity. Below figure ‘message iteration’ shows how ‘order’ calls the ‘orderitem’ objects in a loop to get cost. To
represent loop we need to write ‘For each <<object name>>’. In the below figure the object is the ‘orderitem’. Also note the for each is put in a box to emphasize that
it’s a loop.
Message constraint
If we want to represent constraints it is put in a rectangle bracket as shown in figure ‘message constraint’. In the below figure ‘message constraint’ the ‘customer’ object
can call ‘book tickets’ only if the age of the customer is greater than 10.
Message branching
Below figure ‘message branching’ shows how ‘customer’ object have two branches one is when the customer calls save data and one when he cancels the data.
[Link] 10/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Let’s take a small example to understand sequence diagram practically. Below is a simple voucher entry screen for accounts data entry. Following are the steps how the
accountant will do data entry for the voucher:-
Accountant loads the voucher data entry screen. Voucher screen loads with debit account codes and credit account codes in the respective combo boxes.
Accountant will then fill in all details of the voucher like voucher description, date, debit account code, credit account code, description, and amount and then
click ‘add voucher’ button.
Once ‘add voucher’ is clicked it will appear in the voucher screen below in a grid and the voucher entry screen will be cleared and waiting for new voucher to be
added. During this step voucher is not added to database it’s only in the collection.
If there are more vouchers to be added the user again fills voucher and clicks ‘add voucher’.
Once all the vouchers are added he clicks ‘submit voucher’ which finally adds the group of vouchers to the database.
Below figure ‘Voucher data entry screen’ shows pictorially how the screen looks like.
Figure ‘Voucher data entry sequence diagram’ shows how the sequence diagram looks like. Below diagram shows a full sequence diagram view of how the flow of the
above screen will flow from the user interface to the data access layer. There are three main steps in the sequence diagram, let’s understand the same step by step.
Step 1:- The accountant loads the voucher data entry screen. You can see from the voucher data entry screen image we have two combo boxes debit and credit
account codes which are loaded by the UI. So the UI calls the ‘Account Master’ to load the account code which in turn calls the data access layer to load the accounting
codes.
Step 2:- In this step the accountant starts filling the voucher information. The important point to be noted in this step is that after a voucher is added there is a
conditional statement which says do we want to add a new voucher. If the accountant wants to add new voucher he again repeats step 2 sequence in the sequence
diagram. One point to be noted is the vouchers are not added to database they are added in to the voucher collection.
Step 3:- If there are no more vouchers the accountant clicks submit and finally adds the entire voucher in the database. We have used the loop of the sequence
diagram to show how the whole voucher collection is added to the database.
[Link] 11/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Share
EMAIL TWITTER
Unified modeling language ( UML ) interview questions part 2 Generate and add keyword variations using AdWords API
SOA Interview Questions: Part 1 Window Tabs (WndTabs) Add-In for DevStudio
Search Comments Go
Composition vs Aggreagation
Md. Mazharul Islam Khan 28-Dec-12 18:07
Composition
Chandrasekharan P 12-Dec-11 22:00
My vote of 5
RupeshKumar 21-Sep-11 6:58
My vote of 5
cappzeta 22-Aug-11 11:34
good
rakhi ramtaro 12-Sep-09 15:52
Just wondering...
BoneSoft 23-Sep-08 4:05
[Link] 13/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
Complete BS
pwasser 14-Sep-08 21:59
Re: Complete BS
Shivprasad koirala 15-Sep-08 2:45
Re: Complete BS
Shahbaz Hussain 12-Feb-10 10:22
Re: Complete BS
Shivprasad koirala 1-Mar-10 4:43
well written
CIDev 11-Sep-08 4:21
An error
AlexSr 30-Aug-08 2:44
Refresh 1
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Permalink | Advertise | Privacy | Terms of Use | Mobile Layout: fixed | Article Copyright 2008 by Shivprasad koirala
Select Language ▼
Web02 | 2.8.170630.1 | Last Updated 1 Dec 2008 fluid Everything else Copyright © CodeProject, 1999-2017
[Link] 14/15
05/07/2017 UML Interview Questions Part 1 - CodeProject
[Link] 15/15