UML Interview Questions

What is UML?

UML is Unified Modeling Language. It is a graphical language for visualizing specifying constructing and documenting the artifacts of the system. It allows you to create a blue print of all the aspects of the system, before actually physically implementing the system.

What is modeling? What are the advantages of creating a model?

Modeling is a proven and well-accepted engineering technique which helps build a model. Model is a simplification of reality; it is a blueprint of the actual system that needs to be built. Model helps to visualize the system. Model helps to specify the structural and behavior of the system. Model helps make templates for constructing the system. Model helps document the system.

What are the different views that are considered when building an object-oriented software system?

Normally there are 5 views.
  • Use Case view - This view exposes the requirements of a system. 
  • Design View - Capturing the vocabulary. 
  • Process View - modeling the distribution of the systems processes and threads. 
  • Implementation view - addressing the physical implementation of the system. 
  • Deployment view - focus on the modeling the components required for deploying the system. 

What are diagrams?

Diagrams are graphical representation of a set of elements most often shown made of things and associations.

What are the major three types of modeling used?

Major three types of modeling are structural, behavioral, and architectural.

Mention the different kinds of modeling diagrams used?

Following modeling diagrams are commonly used.
  • Use case diagram 
  • Class Diagram 
  • Object Diagram 
  • Sequence Diagram 
  • State chart Diagram 
  • Collaboration Diagram 
  • Activity Diagram 
  • Component diagram 
  • Deployment Diagram 

What is Architecture?

Architecture is not only taking care of the structural and behavioral aspect of a software system but also taking into account the software usage, functionality, performance, reuse, economic and technology constraints.

What is SDLC?

SDLC is Software Development Life Cycle. SDLC of a system included processes that are Use case driven, Architecture centric and Iterative and Incremental. This Life cycle is divided into phases. Phase is a time span between two milestones. The milestones are Inception, Elaboration, Construction, and Transition. Process Workflows that evolve through these phase are Business Modeling, Requirement gathering, Analysis and Design, Implementation, Testing, Deployment. Supporting Workflows are Configuration and change management, Project management.

What are Relationships?

There are different kinds of relationships: 
  • Dependencies: Dependencies are relations ships between two entities that that a change in specification of one thing may affect another thing. Most commonly it is used to show that one class uses another class as an argument in the signature of the operation. 
  • Generalization: Generalization is relationships specified in the class subclass scenario, it is shown when one entity inherits from other. 
  • Association:  Associations are structural relationships i.e. a room has walls, Person works for a company. 
  • Aggregation: Aggregation is the typical whole/part relationship. This is exactly the same as an association with the exception that instances cannot have cyclic aggregation relationships (i.e. a part cannot contain its whole).
  • Composition: Composition is exactly like Aggregation except that the lifetime of the 'part' is controlled by the 'whole'. This control may be direct or transitive. That is, the 'whole' may take direct responsibility for creating or destroying the 'part', or it may accept an already created part, and later pass it on to some other whole that assumes responsibility for it.
  •  

How are the diagrams divided?

The nine diagrams are divided into static diagrams and dynamic diagrams.
Static Diagrams (Also called Structural Diagram): Class diagram, Object diagram, Component Diagram, Deployment diagram.
Dynamic Diagrams (Also called Behavioral Diagrams): Use Case Diagram, Sequence Diagram, Collaboration Diagram, Activity diagram, Statechart diagram.

What are Messages?

A message is the specification of a communication, when a message is passed that results in action that is in turn an executable statement.

What is an Use Case?

A use case specifies the behavior of a system or a part of a system, óse cases are used to capture the behavior that need to be developed. It involves the interaction of actors and the system.

Can you explain ‘Extend’ and ‘Include’ in use cases?

‘Extend’ and ‘Include’ define relationships between use cases. Below figure ‘Extend and Include’ shows how these two fundamentals are implemented in a project. The below use case represents a system which is used to maintain customer. When a customer is added successfully it should send an email to the admin saying that a new customer is added. Only admin have rights to modify the customer. First lets define extend and include and then see how the same fits in this use case scenario.
  • 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. 

How do we represent private, public and protected in class diagrams?

In order to represent visibility for properties and methods in class diagram we need to place symbols next to each property and method as shown in figure ‘Private, Public and Protected’. ‘+’ indicates that it’s public properties/methods. ‘-‘indicates private properties which means it can not be accessed outside the class. ‘#’ indicate protected/friend properties. Protected properties can only be seen within the component and not outside the component.

Can you explain sequence diagrams?

Sequence diagram shows interaction between objects over a specific period time. 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.

Can you explain primary and secondary actors?

Actors are further classified in to two types primary and secondary actors. Primary actors are the users who are the active participants and they initiate the user case, while secondary actors are those who only passively participate in the use case.

Can you explain use case diagrams?

Use case diagram answers what system does from the user point of view. Use case answer ‘What will the system do?’. Use cases are mainly used in requirement document to depict clarity regarding a system. There are three important parts in a use case scenario, actor and use case.
  • Scenario: A scenario is a sequence of events which happen when a user interacts with the system. 
  • 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.

Can you explain aggregation and composition in class diagrams?

In this Association there are two types mainly Aggregation Association and Composition Association.

Aggregation Association signifies that the child objects can exist without the Aggregated Object. Composition on the other hand represents a strict "has a" relationship wherein child objects are tightly bound to the parent class and life of its instance depends upon lifetime of top level class instance.  For example say we have three classes University class, Department class and the Professor Class. The Department cannot exist without university which means that if University is closed the Department will also be closed. In other words lifetime of the Department depend on the lifetime of University. This is an example of composition. On the other hand instances of Professor class can continue to exist even if a Department is shutdown representing and aggregation association with Department class.

Note: The filled diamond represents the composition and the empty diamond represents the aggregation.
Comments