0% found this document useful (0 votes)
173 views34 pages

2nd Assignments Withs Answers

The document contains answers to multiple questions about UML modeling concepts like activity diagrams, component diagrams, state machines, events, and architectural modeling. For activity diagrams, it provides examples of notations like initial/final states and describes how they can model processes. Component diagrams are explained as a way to break large systems into subsystems, with interfaces and dependencies shown. State machines are defined as modeling object behavior through state transitions in response to events. The types of events - signals, calls, time, and state changes - are outlined. Finally, architectural modeling is summarized as representing the overall system framework using both structure and behavior, with package diagrams used.

Uploaded by

Anas Siddiqui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
173 views34 pages

2nd Assignments Withs Answers

The document contains answers to multiple questions about UML modeling concepts like activity diagrams, component diagrams, state machines, events, and architectural modeling. For activity diagrams, it provides examples of notations like initial/final states and describes how they can model processes. Component diagrams are explained as a way to break large systems into subsystems, with interfaces and dependencies shown. State machines are defined as modeling object behavior through state transitions in response to events. The types of events - signals, calls, time, and state changes - are outlined. Finally, architectural modeling is summarized as representing the overall system framework using both structure and behavior, with package diagrams used.

Uploaded by

Anas Siddiqui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Ques1 What do you mean by activity diagram? Explain in detail.

AKTU 2014-15, Marks 05


OR
What do you mean by activity diagram? What are the two special
states shown in an activity diagram? Explain with an example.
AKTU 2010-11, Marks 05
Answer
Activity diagram is another important diagram in UML to describe the dynamic
aspects of the system.
Activity diagram is basically a flowchart to represent the flow from one activity
to another activity. The activity can be described as an operation of the system.
The control flow is drawn from one operation to another. This flow can be
sequential, branched, or concurrent. Activity diagrams deal with all type of flow
control by using different elements such as fork, join, etc
Example of Activity Diagram
Let us consider mail processing activity as a sample for Activity Diagram.
Following diagram represents activity for processing e-mails.
In the above activity diagram, three activities are specified. When the mail
checking process begins user checks if mail is important or junk. Two guard
conditions [is essential] and [is junk] decides the flow of execution of a process.
After performing the activity, finally, the process is terminated at termination
node.

Activity Diagram Notations


The two important states of activity diagrams are Initial State and Final State
Activity diagrams symbols can be generated by using the following notations:

• Initial states: The starting stage before an activity takes place is depicted as
the initial state
• Final states: The state which the system reaches when a specific process
end is known as a Final State
• State or an activity box:
• Decision box: It is a diamond shape box which represents a decision with
alternate paths. It represents the flow of control.

Activity Diagram Notation and Symbol


Ques 2. Describe in brief Component diagram.
AKTU 2010-11, Marks 05
Answer
Component Diagram
When modeling large object-oriented systems, it is necessary to break down the
system into manageable subsystems. UML component diagrams are used for
modeling large systems into smaller subsystems which can be easily managed.
A component is a replaceable and executable piece of a system whose
implementation details are hidden. A component provides the set of interfaces
that a component realizes or implements. Components also require interfaces to
carry out a function.

So, component diagrams are used for,

• To represent the components of any system at runtime.


• It helps during testing of a system.
• It visualizes the connection between various components.

The purpose of the component diagram can be summarized as

• Visualize the components of a system.


• Construct executables by using forward and reverse engineering.
• Describe the organization and relationships of the components.

Component Diagram
Basic Component Diagram Symbols and Notations

Component
A component is a logical unit block of the system, a slightly higher abstraction
than classes. It is represented as a rectangle with a smaller rectangle in the
upper right corner with tabs or the word written above the name of the
component to help distinguish it from a class.

Interface
An interface (small circle or semi-circle on a stick) describes a group of
operations used (required) or created (provided) by components. A full circle
represents an interface created or provided by the component. A semi-circle
represents a required interface, like a person's input.
Dependencies

Draw dependencies among components using dashed arrows.

Port
Ports are represented using a square along the edge of the system or a
component. A port is often used to help expose required and provided interfaces
of a component.

Ques 3. Explain the deployment diagram. What is the difference


between components and nodes?
AKTU 2014-15, Marks 05
Answer
Deployment diagrams are used to visualize the topology of the physical
components of a system, where the software components are deployed.
Deployment diagrams are used to describe the static deployment view of a
system. Deployment diagrams consist of nodes and their relationships
Purpose of Deployment Diagrams
• They show the structure of the run-time system
• They capture the hardware that will be used to implement the system and
the links between different items of hardware.
• They model physical hardware elements and the communication paths
between them
• They can be used to plan the architecture of a system.
• They are also useful for Document the deployment of software
components or nodes

Ques 4. Define state machine? Draw a state machine diagram for


answering a telephone call.

AKTU 2014-15, Marks 05

Answer
State machine
• A state machine is a behaviour that specifies the sequences of states an
object goes through during its lifetime in response to events.
• Graphically, a state is rendered as a rectangle with rounded corners. A
transition is rendered as a solid directed line.
• State machines are used to specify the behaviour of objects that must
respond to asynchronous stimulus or whose current behaviour depends
on their past.
• State machines are used to model the behaviour of entire systems,
especially reactive systems, which must respond to signals from actors
outside the system.

Ques 5. What do you mean by event? What are the types of events
explain with example?

AKTU 2014-15, Marks 05

Answer
Events

• An event is the specification of a significant occurrence that has a location


in time and space.
• Anything that happens is modeled as an event in UML.
• In the context of state machines, an event is an occurrence of a stimulus
that can trigger a state transition
• Four kinds of events –signals, calls, the passing of time, and a change in
state.
• Events may be external or internal and asynchronous or synchronous.
In UML, each thing that happens is modeled as an event. An event is the
specification of a significant occurrence that has a location in time and space.
A signal, passing of time and change in state are asynchronous events. Calls
are generally synchronous events, representing invocation of an operation.

Types of Events
Signals
A signal is a named object that is sent asynchronously by one object and then
received by another. Exceptions are the famous examples for signals. A signal
may be sent as the action of a state in a state machine or as a message in an
interaction. The execution of an operation can also sends signals.

In UML, we model the relationship between an operation and the events using
a dependency stereotyped with “send”, which indicates that an operation sends
a particular signal.

Call Events

A call event represents the dispatch of an operation from one object to another.
A call event may trigger a state change in a state machine. A call event, in
general, is synchronous.

This means that the sender object must wait until it gets an acknowledgment
from the receiver object which receives the call event. For example, consider
the states of a customer in an ATM application:
Time and Change Events
A time event represents the passage of time. In UML, we model the time event
using the “after” keyword followed by an expression that evaluates a period of
time.

A change event represents an event that represents a change in state or the


satisfaction of some condition. In UML, change event is modeled using the
keyword “when” followed by some Boolean expression.

Sending and Receiving Events


Any instance of a class can receives a call event or signal. If this is a
synchronous call event, the sender is in locked state with receiver. If this is a
signal, then the sender is free to carry its operations without any concern on the
receiver.
In UML, call events are modeled as operations on the class of an object and
signals that an object can receive are stored in an extra component in the class
as shown below:

Ques 6. Explain different types of modelling in object-oriented system


design.

OR

What is UML? Mention the different kinds of modelling diagrams used.

AKTU 2013-14, Marks 05

Answer
The three types of modeling in UML are as follows:
1. Structural modeling:
- It captures the static features of a system.
- It consists of the following diagrams:
1. Classes diagrams
2. Objects diagrams
3. Deployment diagrams
4. Package diagrams
5. Composite structure diagram
6. Component diagram
- This model represents the framework for the system and all the components
exist here.
- It represents the elements and the mechanism to assemble them.
- It never describes the dynamic behaviour of the system.

2. Behavioural modeling:
- It describes the interaction within the system.
- The interaction among the structural diagrams is represented here.
- It shows the dynamic nature of the system.
- It consists of the following diagrams:
1. Activity diagrams
2. Interaction diagrams
3. Use case diagrams
- These diagrams show the dynamic sequence of flow in the system.

3. Architectural modeling:
- It represents the overall framework of the system.
- The structural and the behaviour elements of the system are there in this
system.
- It is defined as the blue print for the entire system.
- Package diagram is used.

Ques 7. What do you understand by architectural modelling? Explain


its various concepts and diagrams with suitable examples.

AKTU 2010-11, Marks 05

OR

Write short notes on architectural modelling with suitable examples


and diagrams.

AKTU 2012-13, Marks 05

Answer
Architectural Modeling
Architectural model represents the overall framework of the system. It contains
both structural and behavioural elements of the system. Architectural models
can be defined as the blueprint of the entire system. Package diagram comes
under architectural modeling.

As stated earlier, architecture can be defined at both a logical and physical level.
You will recall that the logical architecture is the more generic view of the
architecture and how it works with less technical specificity.
The physical architecture, on the other hand, describes in more detail how
the software and systems are designed, including specifics about how the
architecture must fit into different technologies that exist within the organization
and how the software integrates with itself and with other systems. We use
several modeling elements and techniques to describe the physical architecture

Component Diagrams
Components are made up of one or more classes and describe parts of an
application that can be assembled and reused.
A component-based architecture (CBD) is the design of a software system
made up of multiple components. For efficiency, it is important to develop
software based on multiple smaller parts (components), which you can use to
assemble the overall system. This enables you to reuse software components
instead of writing them all from scratch.
Component-based architecture also enables different teams to work on the
software and plug their pieces together using what are called “interfaces.” An
interface is a named set of operations that enable the components to work
together through this interface code.
Interfaces enable you to get and provide information to and from a component
using code specific to the technology on which it is deployed. Figure 4-12 shows
how a component and interface are displayed on a component diagram. The
interface is displayed as a circle, but it can also be displayed as a typical class
with the stereotype of <<interface>>.
Deployment Diagrams
Deployment diagrams represent the runtime architecture of your system. A
deployment diagram can be made up of nodes that represent a piece of hard-
ware that generally has memory and a processor built in. There are two different
types of nodes: processor and device. Figure 4-14 shows what the deployment
diagram elements look like.

Ques 8. What do you mean by a collaboration diagram? Explain


various terms and symbols used in a collaboration used in a
collaboration diagram. How polymorphism is described using a
collaboration diagram? explain using an example.

AKTU 2010-11, Marks 05

OR

What is a collaboration diagram? How polymorphism is represented in


a collaboration diagram? Explain with an example.

AKTU 2011-12, Marks 05

Answer
UML Collaboration Diagram
The collaboration diagram is used to show the relationship between the objects
in a system. Both the sequence and the collaboration diagrams represent the
same information but differently. Instead of showing the flow of messages, it
depicts the architecture of the object residing in the system as it is based on
object-oriented programming. An object consists of several features. Multiple
objects present in the system are connected to each other. The collaboration
diagram, which is also known as a communication diagram, is used to portray
the object's architecture in the system.
Notations of a Collaboration Diagram
Following are the components of a component diagram that are enlisted below:

1. Objects: The representation of an object is done by an object symbol


with its name and class underlined, separated by a colon.
In the collaboration diagram, objects are utilized in the following ways:
o The object is represented by specifying their name and class.
o It is not mandatory for every class to appear.
o A class may constitute more than one object.
o In the collaboration diagram, firstly, the object is created, and then
its class is specified.
o To differentiate one object from another object, it is necessary to
name them.
2. Actors: In the collaboration diagram, the actor plays the main role as it
invokes the interaction. Each actor has its respective role and name. In
this, one actor initiates the use case.
3. Links: The link is an instance of association, which associates the
objects and actors. It portrays a relationship between the objects through
which the messages are sent. It is represented by a solid line. The link
helps an object to connect with or navigate to another object, such that
the message flows are attached to links.
4. Messages: It is a communication between objects which carries
information and includes a sequence number, so that the activity may
take place. It is represented by a labeled arrow, which is placed near a
link. The messages are sent from the sender to the receiver, and the
direction must be navigable in that particular direction. The receiver must
understand the message.
Ques 9. Describe generalization and specialization.

AKTU 2010-11, Marks 05

OR

What do you mean by generalizations? Explain. How is it related with


inheritance?

AKTU 2011-12, Marks 05

OR

Define aggregation and generalization. Explain.

AKTU 2012-13, Marks 05

Answer
A generalization is a relationship between a general kind of thing (called the
superclass or parent) and a more specific kind of thing (called the subclass or
child). Generalization is sometimes called an "is-a-kind-of" relationship: one
thing (like the class Bay Window) is-a-kind-of a more general thing (for example,
the class Window). An object of the child class may be used for a variable or
parameter typed by the parent, but not the reverse.
In other words, generalization means that the child is substitutable for a
declaration of the parent. A child inherits the properties of its parents, especially
their attributes and operations. Often but not always the child has attributes and
operations in addition to those found in its parents. An implementation of an
operation in a child overrides an implementation of the same operation of the
parent; this is known as polymorphism. To be the same, two operations must
have the same signature (same name and parameters). Graphically,
generalization is rendered as a solid directed line with a large unfilled triangular
arrowhead, pointing to the parent, as shown in Figure. Use generalizations
when you want to show parent/child relationships.

Figure. Generalization
A class may have zero, one, or more parents. A class that has no parents and
one or more children is called a root class or a base class. A class that has no
children is called a leaf class. A class that has exactly one parent is said to use
single inheritance; a class with more than one parent is said to use multiple
inheritance.
Most often, you will use generalizations among classes and interfaces to show
inheritance relationships. In the UML, you can also create generalizations
among other kinds of classifiers, such as nodes.

"In contrast to generalization, specialization means creating new


subclasses from an existing class."
Specialization
Specialization is the reverse process of generalization. Here, the distinguishing
features of groups of objects are used to form specialized classes from existing
classes. It can be said that the subclasses are the specialized versions of the
super-class.
The following figure shows an example of generalization and specialization.
Ques 10. Define package. Explain the package diagram with suitable
diagram.

AKTU 2014-15, Marks 05

OR

What are package diagrams and why are they used.

AKTU 2013-14, Marks 05

Answer
Package diagrams are structural diagrams used to show the organization and
arrangement of various model elements in the form of packages. A package is
a grouping of related UML elements, such as diagrams, documents, classes, or
even other packages. Each element is nested within the package, which is
depicted as a file folder within the diagram, then arranged hierarchically within
the diagram. Package diagrams are most commonly used to provide a visual
organization of the layered architecture within any UML classifier, such as a
software system.

Benefits of a package diagram


A well-designed package diagram provides numerous benefits to those looking
to create a visualization of their UML system or project.

• They provide a clear view of the hierarchical structure of the various UML
elements within a given system.
• These diagrams can simplify complex class diagrams into well-ordered
visuals.
• They offer valuable high-level visibility into large-scale projects and
systems.
• Package diagrams can be used to visually clarify a wide variety of
projects and systems.
• These visuals can be easily updated as systems and projects evolve.
Basic components of a package diagram
The makeup of a package diagram is relatively simple. Each diagram includes
only two symbols:

Symbol
Symbol Image Description
Name

Groups common
elements based on
Package
data, behavior, or user
interaction

Depicts the relationship


between one element
Dependency (package, named
element, etc) and
another

These symbols can be used in a variety of ways to represent different iterations


of packages, dependencies, and other elements within a system. Here are the
basic components you’ll find within a package diagram:

• Package: A namespace used to group together logically related


elements within a system. Each element contained within the package
should be a packageable element and have a unique name.
• Packageable element: A named element, possibly owned directly by a
package. These can include events, components, use cases, and
packages themselves. Packageable elements can also be rendered as a
rectangle within a package, labeled with the appropriate name.
• Dependencies: A visual representation of how one element (or set of
elements) depends on or influences another. Dependencies are divided
into two groups: access and import dependencies. (See next section for
more info.)
• Element import: A directed relationship between an importing
namespace and an imported packageable element. This is used to import
select individual elements without resorting to a package import and
without making it public within the namespace.
• Package import: A directed relationship between and importing
namespace and an imported package. This type of directed relationship
adds the names of the members of the imported package to its own
namespace
• Package merge: A directed relationship in which the contents of one
package are extended by the contents of another. Essentially, the content
of two packages are combined to produce a new package.

Ques 11. Write a short note on use case diagram and time diagram with
suitable diagram and their utility in system design.

AKTU 2010-11, Marks 05

Answer
1. Use Case Diagram captures the system's functionality and requirements
by using actors and use cases. Use Cases model the services, tasks,
function that a system needs to perform. Use cases represent high-level
functionalities and how a user will handle the system. Use-cases are the
core concepts of Unified Modelling language modeling.

An example of a use-case diagram


Following use case diagram represents the working of the student management
system:
UML Use Case Diagram

Following are the common notations used in a use case diagram:


Use-case:
Use cases are used to represent high-level functionalities and how the user will
handle the system. A use case represents a distinct functionality of a system, a
component, a package, or a class. It is denoted by an oval shape with the name
of a use case written inside the oval shape. The notation of a use case in UML
is given below:

UML Use Case Notation


Actor:
It is used inside use case diagrams. The actor is an entity that interacts with the
system. A user is the best example of an actor. An actor is an entity that initiates
the use case from outside the scope of a use case. It can be any element that
can trigger an interaction with the use case. One actor can be associated with
multiple use cases in the system. The actor notation in UML is given below.

UML Actor Notation

2. Timing diagrams
Timing diagrams focus on conditions changing within and among lifelines along
a linear time axis. Timing Diagrams describe behaviour of both individual
classifiers and interactions of classifiers, focusing attention on time of
occurrence of events causing changes in the modeled conditions of the
Lifelines.
Following are some important key points of a timing diagram:

1. It emphasizes at that particular time when the message has been sent
among objects.
2. It explains the time processing of an object in detail.
3. It is employed with distributed and embedded systems.
4. It also explains how an object undergoes changes in its form throughout
its lifeline.
5. As the lifelines are named on the left side of an edge, the timing diagrams
are read from left to right.
6. It depicts a graphical representation of states of a lifeline per unit time.
7. In UML, the timing diagram has come up with several notations to simplify
the transition state among two lifelines per unit time.
Ques 12. Discuss in brief basic behavioral modelling?

AKTU 2011-12, Marks 05

OR

What do you understand by basic behavioral modelling?

AKTU 2013-14, Marks 05

Answer
UML behavioral diagrams visualize, specify, construct, and document the
dynamic aspects of a system. The behavioral diagrams are categorized as
follows: use case diagrams, interaction diagrams, state–chart diagrams, and
activity diagrams.
Behavioral Model is specially designed to make us understand behavior and
factors that influence behavior of a System. Behavior of a system is explained
and represented with the help of a diagram. This diagram is known as State
Transition Diagram. It is a collection of states and events. It usually describes
overall states that a system can have and events which are responsible for a
change in state of a system.
So, on some occurrence of a particular event, an action is taken and what action
needs to be taken is represented by State Transition Diagram.
Example :
Consider an Elevator. This elevator is for n number of floors and has n number
of buttons one for each floor.
Elevator’s working can be explained as follows:

• Elevator buttons are type of set of buttons which is there on elevator. For
reaching a particular floor you want to visit, “elevator buttons” for that
particular floor is pressed. Pressing, will cause illumination and elevator
will start moving towards that particular floor for which you pressed
“elevator buttons”. As soon as elevator reaches that particular floor,
illumination gets cancelled.
• Floor buttons are another type of set of buttons on elevators. If a person
is on a particular floor and he wants to go on another floor, then the
elevator button for that floor is pressed. Then, process will be same as
given above. Pressing will cause illumination and elevator to start moving,
and when it reaches on desired floor, illumination gets canceled.
• When there is no request for elevator, it remains closed on current floor.
State Transition Diagram for an elevator system is shown below –

Advantages :

• Behavior and working of a system can easily be understood without any


effort.
• Results are more accurate by using this model.
• This model requires less cost for development as cost of resources can
be minimal.
• It focuses on behavior of a system rather than theories.
Disadvantages :

• This model does not have any theory, so trainee is not able to fully
understand basic principle and major concept of modeling.
• This modeling cannot be fully automated.
• Sometimes, it’s not easy to understand overall result.
• Does not achieve maximum productivity due to some technical issues or
any errors.

Ques 13. What do you understand by classes in object-oriented system


design?

Answer
Class
A class represents a collection of objects having the same characteristic
properties that exhibit common behavior. It gives the blueprint or description of
the objects that can be created from it. Creation of an object as a member of a
class is called instantiation. Thus, an object is an instance of a class.
The constituents of a class are −

• A set of attributes for the objects that are to be instantiated from the class.
Generally, different objects of a class have some difference in the values
of the attributes. Attributes are often referred to as class data.
• A set of operations that portray the behavior of the objects of the class.
Operations are also referred to as functions or methods.

Example
Let us consider a simple class, Circle, that represents the geometrical figure
circle in a two–dimensional space. The attributes of this class can be identified
as follows −

• x–coord, to denote x–coordinate of the center


• y–coord, to denote y–coordinate of the center
• a, to denote the radius of the circle
Some of its operations can be defined as follows −

• findArea(), method to calculate area


• findCircumference(), method to calculate circumference
• scale(), method to increase or decrease the radius

Ques 14. Explain relationship with its different types.

Answer
Relationships in Class Diagrams
Classes are interrelated to each other in specific ways. In particular,
relationships in class diagrams include different types of logical connections.
The following are such types of logical connections that are possible in UML:

• Association
• Directed Association
• Reflexive Association
• Multiplicity
• Aggregation
• Composition
• Inheritance/Generalization
• Realization

Association

Association
is a broad term that encompasses just about any logical connection or
relationship between classes. For example, passenger and airline may be
linked as above:
Directed Association

Directed Association
refers to a directional relationship represented by a line with an arrowhead. The
arrowhead depicts a container-contained directional flow.

Reflexive Association

Reflexive Association
This occurs when a class may have multiple functions or responsibilities. For
example, a staff member working in an airport may be a pilot, aviation engineer,
a ticket dispatcher, a guard, or a maintenance crew member. If the maintenance
crew member is managed by the aviation engineer there could be a managed
by relationship in two instances of the same class.

Multiplicity

Multiplicity is the active logical association when the cardinality of a class in


relation to another is being depicted. For example, one fleet may include
multiple airplanes, while one commercial airplane may contain zero to many
passengers. The notation 0..* in the diagram means “zero to many”.
Aggregation

Aggregation refers to the formation of a particular class as a result of one class


being aggregated or built as a collection. For example, the class “library” is
made up of one or more books, among other materials. In aggregation, the
contained classes are not strongly dependent on the lifecycle of the container.
In the same example, books will remain so even when the library is dissolved.
To show aggregation in a diagram, draw a line from the parent class to the child
class with a diamond shape near the parent class.
To show aggregation in a diagram, draw a line from the parent class to the child
class with a diamond shape near the parent class.

Composition

The composition relationship is very similar to the aggregation relationship. with


the only difference being its key purpose of emphasizing the dependence of the
contained class to the life cycle of the container class. That is, the contained
class will be obliterated when the container class is destroyed. For example, a
shoulder bag’s side pocket will also cease to exist once the shoulder bag is
destroyed.
To show a composition relationship in a UML diagram, use a directional line
connecting the two classes, with a filled diamond shape adjacent to the
container class and the directional arrow to the contained class.

Inheritance / Generalization

Inheritance refers to a type of relationship wherein one associated class is a


child of another by virtue of assuming the same functionalities of the parent
class. In other words, the child class is a specific type of the parent class. To
show inheritance in a UML diagram, a solid line from the child class to the parent
class is drawn using an unfilled arrowhead.

Realization

Realization denotes the implementation of the functionality defined in one class


by another class. To show the relationship in UML, a broken line with an unfilled
solid arrowhead is drawn from the class that defines the functionality of the class
that implements the function. In the example, the printing preferences that are
set using the printer setup interface are being implemented by the printer.

Ques 15. What is the difference between a class diagram and an


instance diagram? Discuss the significance of each.
AKTU 2012-13, Marks 10
Answer
Class diagram Instance Diagram

A class diagram is a schema, pattern An instance diagram describe how does


or template for describing many a particular set of object relates to each
possible instances of data other

It describes general case in


It describes object instance
modelling system

The OMT representation of instance


The OMT symbol for a class is a
diagram, class name in parenthesis at
rectangular box with class name in
the top of the object box and object
boldface. A line is drawn between
name with attribute listed below as
the class name and attributes
shown below

The purpose of class diagram is to model the static view of an application.


Class diagrams are the only diagrams which can be directly mapped with
object-oriented languages and thus widely used at the time of construction.

UML diagrams like activity diagram, sequence diagram can only give the
sequence flow of the application, however class diagram is a bit different. It
is the most popular UML diagram in the coder community.

The purpose of the class diagram can be summarized as −

• Analysis and design of the static view of an application.


• Describe responsibilities of a system.
• Base for component and deployment diagrams.
• Forward and reverse engineering.

Instance Diagrams

The purpose of a diagram should be understood clearly to implement it


practically. The purposes of object diagrams are similar to class diagrams.
The difference is that a class diagram represents an abstract model
consisting of classes and their relationships. However, an object diagram
represents an instance at a particular moment, which is concrete in nature.

It means the object diagram is closer to the actual system behavior. The
purpose is to capture the static view of a system at a particular moment.

The purpose of the object diagram can be summarized as −

• Forward and reverse engineering.


• Object relationships of a system
• Static view of an interaction.
• Understand object behaviour and their relationship from practical
perspective

Ques 16. Explain class and object diagrams with examples.

AKTU 2013-14, Marks 05

Answer
Class Diagrams

• Class diagram is a static diagram. It represents the static view of an


application.
• Class diagram is not only used for visualizing, describing, and
documenting different aspects of a system but also for constructing
executable code of the software application.
• Class diagram describes the attributes and operations of a class and also
the constraints imposed on the system. The class diagrams are widely
used in the modeling of object-oriented systems because they are the
only UML diagrams, which can be mapped directly with object-oriented
languages.
• Class diagram shows a collection of classes, interfaces, associations,
collaborations, and constraints. It is also known as a structural diagram.
Class diagrams are the main building block in object-oriented modeling. They
are used to show the different objects in a system, their attributes, their
operations and the relationships among them.
The following figure is an example of a simple class:

Simple class diagram with attributes and operations


In the example, a class called “loan account” is depicted. Classes in class
diagrams are represented by boxes that are partitioned into three:

1. The top partition contains the name of the class.


2. The middle part contains the class’s attributes.
3. The bottom partition shows the possible operations that are associated
with the class.

Object Diagrams

• Object diagrams are derived from class diagrams so object diagrams are
dependent upon class diagrams.
• Object diagrams represent an instance of a class diagram. The basic
concepts are similar for class diagrams and object diagrams. Object
diagrams also represent the static view of a system but this static view is
a snapshot of the system at a particular moment.
• Object diagrams are used to render a set of objects and their
relationships as an instance.
Object Diagrams use real world examples to depict the nature and structure of
the system at a particular point in time. Since we are able to use data available
within objects, Object diagrams provide a clearer view of the relationships that
exist between objects.
Figure – a class and its corresponding object

Ques 17. Prepare a portion of an object diagram for a library book


checkout system that shows the date a book is due and the late charges
for an overdue book as derived objects.
AKTU 2011-12, Marks 05

Answer

Fine_amount = (date_returned - due_date)* type.finr_perDay


Ques 18. Differentiate between a class and object with some example.
Also prepare a list of objects that you would expect each of the following
systems to handle:

• a program for laying out a newspaper


• a catalogue store order entry system
Answer
Class Object
A class is a blueprint from which An object is the instance of the class, which
you can create the instance, i.e., helps programmers to use variables and
objects. methods from inside the class.

A class is used to bind data as


well as methods together as a Object acts like a variable of the class.
single unit.

Classes have logical existence. Objects have a physical existence.

A class doesn't take any


An object takes memory when a programmer
memory spaces when a
creates one.
programmer creates one.

The class has to be declared Objects can be declared several times


only once. depending on the requirement.

Figure – a class and its corresponding object

You might also like