04 | 07 | 2009
Interview Questions on UML, Use Case Diagrams, CLass Diagram and Sequence Diagram
Written by Java King   
Sunday, 18 May 2008 16:58

Rating 3.7/5 (6 votes)

Q: What is UML?

A: UML stands for unified modeling language. It is a graphical language which is used to document and share Use Cases, High Level Design, Low Level Design, Flow Sequences and even Collaboration using blocks and shapes.

 

Q: What is the purpose of UML?

A: UML communicates things visually which is easy to understand and grasp. When you represent things graphically, you will be able to think of more ideas and also to work out the consequences of your decisions. People think in pictures and a picture can express a lot of ideas in a quick way. UML is a standard way to draw various views of a piece of software: the user's view, the architecture, the internal structure of the software, the source code, and the hardware involved.

 

Q: What are the different views that are commonly used when developing Software in Java?

A:

1) Use Case View - Describes the system from the User’s point of view, Describes the various functionalities expected from the system to be developed and how user is going to interact with those features.

2) Class Diagram – Shows graphically the relationships between classes and packages.

3) Sequence Diagram – Shows the sequence of method calls and interactions between classes.

4) Component Diagram - Shows the components within the system and the interaction between components.

 

Q: Explain Use Case View?

A: Use Case views or diagrams describe the system from the User’s point of view, and the various functionalities expected from the system to be developed and how user is going to interact with those features. A use case diagram mainly consists of an actor (the user) and other use case diagrams and use cases. Use case view is the first activity in UML; from use case view other views like class diagram and sequence diagrams are derived. This makes it easy to map user requirements to implementation details like classes and flows.

 

Q: Draw a sample Usecase Diagram.

Use Case Diagram Example

 

 

Q: What is a Use Case ?

A: A use case names a type of user (actors) and something that they want to do (use case). The use case describes how an actor achieves a specific tangible goal. The important part of a use case is the description of the steps that the actors take to achieve their goals and how the system appears to respond to the actor’s actions.

 

Q: What is an Actor?

A: An actor is the person or entity who is going to use the software. An actor can be a human, a device, or a piece of software but it must not be part of the system we are producing.

 

Q: What are the rules for defining an Actor?

A: The actors must not be part of the software that you are describing. They are outside it and only use it. They can be people, machines, or other software. Usecase names must describe some activity that an actor wants to do. A simple rule is to start each use case name with a strong verb: "Review grade", "update record", "Get money from ATM", and "Control nuclear reactor" are good names. "Grades" and "do email" are bad ones. Avoid having a large number of overly simple use cases that can be covered by one simple one: Instead of "add record", "change record", "delete record", "print record",.... etc use "Access and update record", for example . We can use scenarios to show more details.

 

Q: What is a Scenario?

A: Each use case will need to be described in more detail how to implement it. A scenario describes, step by step, how a particular user gets what they want from the computer. It says what the user does and what the computer does as a result. However it does not spell out all the details -- things like whether there is a tool bar or the color of the screen is best left out.


 

Q: What is a Class Diagram?

A: Class diagrams show the classes of the system, their interrelationships (including inheritance, aggregation, and association), and the operations/functions and attributes/member variables of the classes.

 

Q: How are classes represented in a class diagram?

A: Classes are represented by rectangular boxes, the top half of the box lists the attributes/variables in the class and the bottom portion lists the operations/functions in the class.

For Example:

UML Representation of a class

 

 

Q: What are the different kinds of relationships in Class diagram?

A:

1) Instance Level Relationships

a. Association

b. Aggregation

c. Composition

2) Class Level Relationships

a. Generalization

b. Realization

3) General Relationships

a. Dependency

b. Multiplicity

 

Q: What is Association?

A: Association defines a relationship between classes of objects which allows one object instance to cause another to perform an action on its behalf. When two objects are associated, one object will be having a variable that points to the other object. In bi directional association both the objects will be using each other. Binary associations are represented by a line with each end connected to a class block.

For Example:

UML representation of Association

 

 

Q: What is Aggregation?

A: Aggregation is a variant of the "has a" or association relationship; aggregation is more specific than association. It is an association that represents a part-whole relationship which means that one object contains another object. Aggregation can occur when a class is a collection or container of other classes, but where the contained classes do not have a strong life cycle dependency on the container--essentially, if the container is destroyed, its contents are not. In UML, it is graphically represented as a clear diamond shape on the containing class end of the tree of lines that connect contained class(es) to the containing class.

For Example:

UML Representation of Aggregation

 

 

 

Q: What is Composition?

A: Composition is a stronger variant of the "has a" or association relationship; composition is more specific than aggregation. It is represented with a solid diamond shape. Composition has a strong life cycle dependency between instances of the container class and instances of the contained class(es): If the container is destroyed, every instance that it contains is destroyed as well. The UML graphical representation of a composition relationship is a filled diamond shape on the containing class end of the tree of lines that connect contained class(es) to the containing class.

For Example:

UML Representation of Composition

 

In the above picture the relationship between Car and Carburetor is Composition, The Carburetor cannot be used without a Car. But the relationship between Pond and Duck is Aggregation i.e. Pond has many ducks but ducks can be associated with more than one pond.

 

Q: What is Generalization?

A: The generalization relationship is also known as the inheritance or "is a" relationship. When one class inherits or extends another class, it is called Generalization. Formally, The Generalization relationship indicates that one of the two related classes (the subtype) is considered to be a specialized form of the other (the super type) and super type is considered as Generalization of subtype.

In UML diagrams generalization is shown as a Closed but unfilled arrow pointing from the child class to the parent class.

For Example:

UML Representation of Generalization

In the above example, Person is the Parent or generalized class and the Student and Professor classes are child or specialized classes.

 

Q: What is Realization?

A: In java when one class implements and interface it is called realization, the class realizes the interface. Formally, realization relationship is a relationship between two model elements, in which one model element (the client) realizes the behavior that the other model element (the supplier) specifies. A realization is displayed in a UML diagram as a dashed line with an unfilled arrowhead towards the supplier.

For Example:

UML Representation of Realization

In the above example, the HTMLParser class realizes the Parser class.



 

Q: What is a Sequence Diagram?

A: Sequence diagram is used to represent the interactions that happen between objects during an activity or process. The objects are represented as vertical lines called lifelines and the messages exchanged between them are represented as horizontal arrows. This allows the specification of simple runtime scenarios in a graphical manner. The object names will be written on a box above the lifelines and the name of the method/ message called is written on the top of the arrow, The direction of the arrow indicated the direction of method call or message flow.

For Example:

A Sequence Diagram

 

Q: What are activation boxes in a sequence diagram?

A: Activation boxes are the opaque rectangular boxes drawn over the lifelines at points where a method is called. They are also called method call boxes.

 

Q: When one method call to a class results in several method calls to other classes how is it represented?

A: When a method is called there it will be from a method call box on the caller’s life line and will be connected to a method call box on the called object’s life line. The method box of the called method’s lifeline will make multiple calls to one or several other classes.

For Example:

 

 

Comments
Add New Search
Anonymous   |41.234.130.xxx |2008-09-30 05:39:26


Anonymous   |41.234.130.xxx |2008-09-30 05:40:20
cscsscsc
Anonymous   |203.91.207.xxx |2009-03-11 03:17:03
Code:
Quote:
Anonymous   |203.91.207.xxx |2009-03-11 03:17:45
greatt...........
loooloow  - Thanks alot   |84.18.72.xxx |2009-05-02 16:29:06
???? ???? ....
thank alot
aruna   |124.43.56.xxx |2009-05-29 23:42:55
prasant   |203.192.228.xxx |2009-06-02 14:03:11
really nice
guest   |119.153.60.xxx |2009-06-13 07:45:45
thanx
Anonymous   |212.12.160.xxx |2009-06-17 05:58:39
great one,,,

Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
 
Please input the anti-spam code that you can read in the image.

3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Sunday, 12 April 2009 09:05 )