0% found this document useful (0 votes)
56 views43 pages

Object Oriented Analysis and Design: Dr. Babasaheb Ambedkar Open University Ahmedabad

Uploaded by

maulik shah
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)
56 views43 pages

Object Oriented Analysis and Design: Dr. Babasaheb Ambedkar Open University Ahmedabad

Uploaded by

maulik shah
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/ 43

OBJECT ORIENTED ANALYSIS AND DESIGN

PGDCA -204

BLOCK 1:
OBJECT ORIENTED
MODELLING

Dr. Babasaheb Ambedkar Open University


Ahmedabad
OBJECT ORIENTED ANALYSIS AND
DESIGN

Knowledge Management and


Research Organization
Pune
Editorial Panel

Author
PROF. K J Sharma

Language Editor
Mr. Vipul Shelke

Graphic and Creative Panel


Ms. K. Jamdal
Ms. Lata Dawange
Mr. Prashant Tikone

Copyright © 2015 Knowledge Management and Research Organization.


All rights reserved. No part of this book may be reproduced, transmitted or utilized
in any form or by means of, electronic or mechanical, including photocopying,
recording or by any information storage or retrieval system without written
permission from us.

Acknowledgment
Every attempt has been made to trace the copyright holders of material reproduced
in this book. Should an infringement have occurred, we apologize for the same and
will be pleased to make necessary correction/amendment in future edition of this
book.
The content is developed by taking reference of online and print publications that
are mentioned in Bibliography. The content developed represents the breadth of
research excellence in this multidisciplinary academic field. Some of the
information, illustrations and examples are taken "as is" and as available in the
references mentioned in Bibliography for academic purpose and better
understanding by learner.'
ROLE OF SELF INSTRUCTIONAL MATERIAL IN DISTANCE LEARNING

The need to plan effective instruction is imperative for a successful


distance teaching repertoire. This is due to the fact that the instructional
designer, the tutor, the author (s) and the student are often separated by
distance and may never meet in person. This is an increasingly common
scenario in distance education instruction. As much as possible, teaching by
distance should stimulate the student's intellectual involvement and
contain all the necessary learning instructional activities that are capable of
guiding the student through the course objectives. Therefore, the course /
self-instructional material are completely equipped with everything that
the syllabus prescribes.
To ensure effective instruction, a number of instructional design
ideas are used and these help students to acquire knowledge, intellectual
skills, motor skills and necessary attitudinal changes. In this respect,
students' assessment and course evaluation are incorporated in the text.
The nature of instructional activities used in distance education self-
instructional materials depends on the domain of learning that they
reinforce in the text, that is, the cognitive, psychomotor and affective. These
are further interpreted in the acquisition of knowledge, intellectual skills
and motor skills. Students may be encouraged to gain, apply and
communicate (orally or in writing) the knowledge acquired. Intellectual-
skills objectives may be met by designing instructions that make use of
students' prior knowledge and experiences in the discourse as the
foundation on which newly acquired knowledge is built.
The provision of exercises in the form of assignments, projects and
tutorial feedback is necessary. Instructional activities that teach motor skills
need to be graphically demonstrated and the correct practices provided
during tutorials. Instructional activities for inculcating change in attitude
and behavior should create interest and demonstrate need and benefits
gained by adopting the required change. Information on the adoption and
procedures for practice of new attitudes may then be introduced.
Teaching and learning at a distance eliminates interactive
communication cues, such as pauses, intonation and gestures, associated
with the face-to-face method of teaching. This is particularly so with the
exclusive use of print media. Instructional activities built into the
instructional repertoire provide this missing interaction between the
student and the teacher. Therefore, the use of instructional activities to
affect better distance teaching is not optional, but mandatory.
Our team of successful writers and authors has tried to reduce this.
Divide and to bring this Self Instructional Material as the best teaching
and communication tool. Instructional activities are varied in order to assess
the different facets of the domains of learning.
Distance education teaching repertoire involves extensive use of self-
instructional materials, be they print or otherwise. These materials are
designed to achieve certain pre-determined learning outcomes, namely goals
and objectives that are contained in an instructional plan. Since the teaching
process is affected over a distance, there is need to ensure that students actively
participate in their learning by performing specific tasks that help them to
understand the relevant concepts. Therefore, a set of exercises is built into the
teaching repertoire in order to link what students and tutors do in the
framework of the course outline. These could be in the form of students'
assignments, a research project or a science practical exercise. Examples of
instructional activities in distance education are too numerous to list.
Instructional activities, when used in this context, help to motivate students,
guide and measure students' performance (continuous assessment)
PREFACE
We have put in lots of hard work to make this book as user-friendly
as possible, but we have not sacrificed quality. Experts were involved in
preparing the materials. However, concepts are explained in easy language
for you. We have included many tables and examples for easy
understanding.
We sincerely hope this book will help you in every way you expect.
All the best for your studies from our team!
OBJECT ORIENTED ANALYSIS AND DESIGN
Contents

BLOCK 1: OBJECT ORIENTED MODELLING


UNIT 1 INTRODUCTION TO OBJECT ORIENTED MODELLING
Object Oriented Modeling, Characteristics Object Oriented Modeling:
Class and Objects, Links and Association, Generalization and
Inheritance, An Object Model. Benefits of OO Modeling, Introduction to
OOAD tools,
UNIT 2 ADVANCE MODELING CONCEPTS
Aggregation, Abstract Class, Multiple Inheritance, Generalization as an
Extension, Generalization as a Restriction, Metadata, Constraints, An
Object Model

BLOCK 2: OBJECT ORIENTED ANALYSIS AND SYSTEM DESIGN

UNIT 1 OBJECT ORIENTED ANALYSIS


Object Oriented Analysis, Problem Statement: an Example, Differences
between Structured Analysis and Object Oriented Analysis, Analysis
Techniques: Object Modeling, Dynamic Modeling, and Functional
Modeling. Adding Operations. Analysis Iteration
UNIT 2 SYSTEM DESIGN
System Design: An Object Oriented Approach, Breaking into
Subsystems, Concurrency Identification, Management of data store,
Controlling events between Objects, Handling Boundary Conditions
BLOCK 3: OBJECT DESIGN AND DYNAMIC MODELING

UNIT 1 OBJECT DESIGN


Object Design for Processing, Object Design Steps, Designing a
Solution, Choosing Algorithms, Choosing Data Structures, Defining
Classes and delegation of Responsibilities to Methods
UNIT 2 DYNAMIC MODELING
Events, State and State Diagram, Elements of State Diagrams,
Examples of State Diagrams, Advance Concepts in Dynamic Modeling,
Concurrency, A Dynamic model

BLOCK 4: FUNCTIONAL MODELING AND UML

UNIT 1 FUNCTIONAL MODELING


Functional Models, Data Flow Diagrams, Features of a DFD, Design
flaws in DFD, A Functional model, Relationship between Object,
Dynamic, and Functional Models
UNIT 2 USING UML
UML: Introduction, Object Model Notations: Basic Concepts, Structural
Diagrams: Class, Object, Composite, Package, Component, Deployment.
Behavioral Diagrams: Use Case, Communication, Sequence, Interaction
Overview, Activity, State. Modeling with Objects
UNIT 3 CASE STUDY
This unit will cover all the OOAD aspects Covered in previous units of
this course.
Dr. Babasaheb PGDCA-204
Ambedkar
Open University

OBJECT ORIENTED ANALYSIS AND DESIGN

BLOCK 1: OBJECT ORIENTED MODELLING

UNIT 1
INTRODUCTION TO OBJECT ORIENTED MODELLING 03

UNIT 2
ADVANCE MODELING CONCEPTS 17
BLOCK 1: OBJECT ORIENTED
MODELING
Block Introduction
Programming languages make it easier to design and implement
programming ideas, by ensuring that you don't have to learn binary, which is the
series of on/off or 1/0 commands the computer uses to calculate everything. The
JVM is an abstract instead of actual machine or processor. It specifies certain
instructions set, register sets, stack, garbage heap as well as required method. The
Java program is a set of instructions which a computer understand.
In this block, we will detail about object oriented modelling features as new
thinking technology for problem solving with knowledge on visualization in real
world. The block will focus on the study and concept of generalization and
inheritance abstractions in terms of structure and behaviour sharing of classes and
relationship. You will give an idea on metadata with respect to data or data
describing other data.
In this block, you will make to learn and understand about the basic of
Inheritance process in terms of object properties and usability in information. The
concept related to generalization with its shared characteristics in terms of classes
and super class. The shared characteristics with respect to attributes, associations
or methods are well detailed to you.

Block Objective
After learning this block, you will be able to understand:

 About features of Object Oriented Modeling

 About advantages of Object Oriented Modeling

 About qualities of Class and Objects

 About qualities of Links and Association

 About Object and Class

 About Multiple Inheritance

 About generalization as a Restriction

1
Object Block Structure
Oriented
Unit 1: Introduction to Object Oriented Modelling
Modeling
Unit 2: Advance Modelling Concepts

2
UNIT 1: INTRODUCTION TO OBJECT
ORIENTED MODELLING
Unit Structure
1.0 Learning Objectives
1.1 Introduction

1.2 Object Oriented Modelling


1.3 Characteristics Object Oriented Modelling: Class and Objects

1.4 Links and Association


1.5 Generalization and Inheritance

1.6 An Object Model


1.7 Benefits of OO Modelling

1.8 Introduction to OOAD tools


1.9 Let Us Sum Up
1.10 Answers for Check Your Progress

1.11 Glossary
1.12 Assignment

1.13 Activities
1.14 Case Study
1.15 Further Readings

1.0 Learning Objectives


After learning this unit, you will be able to understand:

 The basics of object oriented Modeling

 Define Objects and Classes

 Explain the concepts of links and Associations

 Explain the concept of Generalization and Inheritance

 Describe benefits of Object Oriented Modeling

3
Object 1.1 Introduction
Oriented
Modeling Object-oriented technology is incredibly wide and extensive. The users of
computer systems found the effects of such technology as increasingly easy-to-use
software applications and operating systems that are flexible that's catered by
many industries like banking, telecommunications and television. Just in case of
software technology, such object-oriented technology can cover object-oriented
management of projects, computer hardware and computer aided software
engineering, among others.

An interface is mixture of abstract methods. A class implements an


interface, and can inherit abstract ways of interface. It‟s not a class, however if we
tend to write it, it's equivalent to writing a class. Any it's seen that a class
describes itself as an attributes and behaviours of an object. An interface contains
behaviours that a class implements.

1.2 Object Oriented Modelling


It is one of the most objectives of the software engineering discipline to
support the complicated and thus error-prone software development task by
providing appropriate sophisticated concepts, languages, techniques, and tools to
any or all stakeholders involved. A crucial and nowadays commonly accepted
approach within software engineering is that the usage of a software development
process model, where above all the software development task is separated into a
series of dedicated subtasks. a substantial constituent of such a stepwise approach
is the development of a system model. Such a model describes the requirements
for the software system to be realized and forms an abstraction.

Fig 1.1 Model Representations

The success of object-oriented modelling approaches was hindered within


the beginning of the 90ies due to the very fact that surely over 50 object-oriented
4
modelling approaches claimed to be the proper one. This so-called technique war Introduction to
came to an end through an industrial initiative, that pushed the development of the Object Oriented
Modelling
meanwhile industrially standardized object-oriented modelling language UML.

Check your progress 1


1. What is object oriented modeling strategy?
a. Use of algorithms

b. Use of objects
c. Use of classes

d. Both B and C

1.3 Characteristics Object Oriented Modelling: Class and


Objects
Object oriented modelling is entirely a brand new way of thinking about
problems. This methodology is all concerning visualizing the items by using
models organized around real world ideas. Object oriented models help in
understanding issues, communicating with experts from a distance, modelling
enterprises, and designing programs and database. In object oriented modelling
objects and their characteristics are described. In any system, objects come into
existence for playing some role. In the method of defining the roles of objects,
some options of object orientation are used.

Class and Objects


A class is a collection of things, or ideas that have the same characteristics.
Each of these things or concepts is named as object. Classes define the basic
words of the system being modelled. Using a set of classes as the core vocabulary
of a software project tends to greatly facilitate understanding and agreement
concerning the meanings of terms, and other characteristics of the objects in the
system. Classes can serve as the foundation for data modelling. In OOM, the term
classes is sometimes the base from that visual modelling tools−such as Rational
Rose XDE, Visual Paradigm function and design the model of systems.

A class could be a pattern, template, or blueprint for a category of structurally


identical items. The items created using the class are known as instances. This is
5
Object often referred to as the "class or `cookie cutter'" view. As you might guess, the
Oriented instances are the "cookies."
Modeling
A class could be a thing that consists of both a pattern and a mechanism for
creating items supported that pattern. This is the "class as an `instance factory'"
view; instances are the individual items that are "manufactured" using the class's
creation mechanism.
A class is the set of all items created using a specific pattern. In another
way, the class is that the set of all instances of that pattern.

Fig 1.2 Class Notations

Objects
Objects are physical as they are present in universe around us. It is found
that hardware; software, documents and concepts are all object samples. For use
of modelling, an officer views staff, buildings, divisions, documents and benefits
packages as related objects. An automobile person would see tires, doors, engines,
speed and fuel level in terms of objects, while atoms, molecules, volumes, and
temperatures are objects according to chemist which can be thought of as making
an object oriented simulation of chemical reaction.
Normally it is viewed that objects can be considered as particular state. The
state of an object is basically the condition of an object, or set of circumstances
describing the item. It is generally seen that that people are talking about state
information which in particular relates to specific object. It is noticed that state of
bank account object will cover latest and available balance, which shows state of
clock object that is available at required time showing state of lightweight bulb
which could be placed at on or off state. For complex objects like a human being
or an automobile, an entire description of the state may be very complex.
Fortunately, when we use objects to model real world or imagined things, we have

6
a tendency to generally restrict the possible states of the objects to only people Introduction to
who are relevant to our models. Object Oriented
Modelling

Check your progress 2


1. What is class?

a. Collection of similar objects.


b. Collection of different types of objects

c. Group of information
d. None of these

1.4 Links and Association


Links and association are modes of creating link which exists among objects
and classes. It is noticed that both links and association bears similar feature
whereas links establishes among objects while association establishes among
class.
Links: In object modelling links provides a relationship between the objects.
These objects or instance may be same or different in data structure and
behaviour. Thus a link is a physical or conceptual connection between instances
(or objects).
Associations: the object modelling describes as a group of links with
common structure and customary semantics. All the links among the object are the
varieties of association among the same classes. The association is that the
relationship among classes.
1. Association

2. Association with inverse direction


3. Association between student and university

Degree of association is:


1. Unary association (degree of one)

2. Binary Association (degree of two)


3. Ternary Association (degree of three)

7
Object 4. Quaternary Association (degree of four)
Oriented 5. Higher order association (more than four)
Modeling

Check your progress 3


1. What is meant by link in object modeling?

a. Way to describe association


b. Physical or conceptual connection between instances

c. Relationship between classes


d. None of these

1.5 Generalization and Inheritance


Generalization and inheritance are powerful abstractions for sharing the
structure and/or behaviour of one or a lot of classes. Generalization is that the
relationship between a class and it defines a hierarchy of abstraction in which
subclasses (one or more) inherit from one or more super classes. The notation for
generalization is a triangle connecting a super class to its subclasses. The super
class is connected by a line to the top of the triangle. The subclasses are connected
by lines to a horizontal bar attached to the base of the triangle.

8
Introduction to
Object Oriented
Modelling

Fig 1.3 Generalisation Concepts

Inheritance is taken within the sense of code reuse within the object oriented
development. Throughout modelling, we look at the resulting classes, and try to
group similar classes along so code utilize can be enforced. Generalization,
specialization, and inheritance have terribly close association. Generalization is
used to refer to the relationship among classes, and inheritance is employed for
sharing attributes and operations using the generalization relationship.
Inheritance and generalisation have in common that they both have the
ability to define an abstract "contract" or "protocol" that a group of concrete
classes following this "contract" have to implement. this gives you the ability to
handle a number of comparable classes in an exceedingly uniform way, that
permits you to write down additional compact, abstract code, that once more
permits code reuse. Consider a class implements interface example where one
interface extends another interface as:
interface Printable{

void print();
}

interface Showable extends Printable{


void show();

9
Object }
Oriented class Testinterface2 implements Showable
Modeling
{

public void print(){System.out.println("Sanjay");}


public void show(){System.out.println("Mathur");}

public static void main(String args[]){


Testinterface2 obj = new Testinterface2();
obj.print();

obj.show();
}

}
If we run this program we get an output as:

Sanjay
Mathur

Check your progress 4


1. What is inheritance?
a. Code reuse within object modeling

b. Getting properties of one class into another class


c. It is meant for sharing attributes.

d. All of these

1.6 An Object Model


The object model visualizes all the elements in a software application in
terms of objects. The example of Object Model is shown in fig 1.3

10
Introduction to
Object Oriented
Modelling

Fig 1.3 Object Model

 An object contains values stored in instance variables within the object.

 Unlike the record-oriented models, these values are themselves objects.

 Thus objects contain objects to an arbitrarily deep level of nesting.

 An object also contains bodies of code that operate on the the object.

 These bodies of code are called methods.

 Objects that contain the same types of values and the same methods are
grouped into classes.

 A class may be viewed as a type definition for objects.

 Analogy: the programming language concept of an abstract data type.

 The only way in which one object can access the data of another object is by
invoking the method of that other object.

 This is called sending a message to the object.

11
Object Check your progress 5
Oriented
Modeling 1. What is meant by sending message to object?
a. Passing parameters to object

b. Invoking the method of another object


c. Passing one object definition to another

d. None of these

1.7 Benefits of OO Modelling


Here are a number of the advantages of the object-oriented approach:

Reduced Maintenance: the first goal of object-oriented development is that the


assurance that the system can enjoy a longer life while having far smaller
maintenance costs. As a result of most of the processes among the system is
encapsulated, the behaviours is also reused and incorporated into new behaviours.
Real-World Modelling: Object-oriented system tends to model the real world in
a lot of complete fashion than do traditional methods. Objects are organized into
classes of objects, and objects are related to behaviours. The model relies on
objects, rather than on data and processing.
Improved reliability and Flexibility: Object-oriented system promise to be far
more reliable than traditional systems, primarily because new behaviours is "built"
from existing objects. Because objects is dynamically called and accessed, new
objects could also be created at any time. The new objects might inherit data
attributes from one, or several other objects. Behaviours are also inherited from
super-classes, and novel behaviours are also added without effecting existing
systems functions.

High Code Reusability: once a new object is created, it'll automatically inherit
the data attributes and characteristics of the class from that it absolutely were
spawned. The new object will inherit the data and behaviours from all super
classes in which it participates. Once a user creates a new type of a widget, the
new object behaves "wigitty", while having new behaviours that are defined to the
system.

12
Check your progress 6 Introduction to
Object Oriented
1. What are the benefits of object oriented modeling? Modelling

a. Improved reliability

b. Improved flexibility
c. Reduced maintenance

d. All of these

1.8 Introduction to OOAD tools


The major phases of software development using object–oriented
methodology are object-oriented analysis, object-oriented design, and object-
oriented implementation. Object–Oriented Analysis is a stage where the problem
is formulated, user requirements are identified, and model is created on real–world
objects. The analysis produces models on how the desired system should function
and how it must be developed. The models do not include any implementation
details so that it can be understood and examined by any non–technical
application expert. Object–Oriented Design includes two main stages, namely,
system design and object design.
There are three main tools used in object-oriented analysis and design techniques:

 Class diagrams/templates.

 Object diagrams.

 Object state diagrams

Class diagrams are used to model key abstractions in the problem domain
and their relationships with each other. Object diagrams are used to model the
interactions between objects, whereas object state diagrams model the dynamic
behaviour within a single object. An object state diagram shows all the possible
states of an object and the allowed transition between the states.

13
Object Check your progress 7
Oriented
Modeling 1. What are the two main stages of object –oriented design?
a. System design

b. Object design
c. Both of these

d. None of these

1.9 Let Us Sum Up


In this unit we have learnt that object oriented technology is wide and
extensive which increases easy-to-use software applications with operating
systems that is flexible. It is seen that object oriented modelling is brand new way
of thinking about problems in which you can visualize items by modelling that are
arranged around real world ideas.
It is known that class consists of pattern and mechanism for creating items
which supports pattern where class as an instance factory can be seen as an
instance of individual items manufactured by class creation mechanism. We have
studied that links and association are modes of creating link that exists in objects
and classes with both links and association bears same feature and establishes link
among objects and association establishes class.
The generalization and inheritance are strong abstractions for sharing
structure and behaviour of classes and bears relationship among class and show
branch of abstraction where subclasses inherit from super classes. The object
oriented analysis is particular stage where problem gets framed with identification
of user requirements and creation of modelling in real world objects.

1.10 Answers for Check Your Progress

Check your progress 1

Answers: (1 –d)

Check your progress 2

Answers: (1 –a)
14
Check your progress 3 Introduction to
Object Oriented
Answers: (1 –b) Modelling

Check your progress 4

Answers: (1 –d)

Check your progress 5

Answers: (1 –b)

Check your progress 6

Answers: (1 –d)

Check your progress 7

Answers: (1 –c)

1.11 Glossary
1. Package - It is a collection of types that gives access protection and name
space management in Java.
2. Interface - In programming, interface is a mixture of abstract methods
where class implements an interface.

1.12 Assignment
Explain the Object oriented modelling and its advantages.

1.13 Activities
Study OOAD tools.

15
Object 1.14 Case Study
Oriented
Modeling Study the difference between generalisation and specialisation and also
justify how they are useful in Object oriented modelling

1.15 Further Readings


1. Learning Programming by Peter Norvig's.

2. Approach programming with a more positive by P.Brian.Mackey.

16
UNIT 2: ADVANCE MODELING CONCEPTS
Unit Structure
2.0 Learning Objectives

2.1 Introduction
2.2 Aggregation

2.3 Abstract Class


2.4 Multiple Inheritance

2.5 Generalization as an Extension


2.6 Generalization as a Restriction

2.7 Metadata
2.8 Constraints

2.9 An Object Model


2.10 Let Us Sum Up

2.11 Answers for Check Your Progress


2.12 Glossary

2.13 Assignment
2.14 Activities

2.15 Case Study


2.16 Further Readings

2.0 Learning Objectives


After learning this unit, you will be able to understand:

 Study about features of Object Model

 Study about advantages of Abstract Class

 Study about Multiple Inheritance

 Study about Extension and Restriction

17
Object 2.1 Introduction
Oriented
Modeling Inheritance are often defined as the process wherever one object acquires the
properties of another. With the use of inheritance the information is made
manageable in a hierarchical order. Once we talk about inheritance, the most
unremarkably used keyword would be extends and implements. These words
would determine whether one object IS-A style of another. By using these
keywords we will create one object acquires the properties of another object.
Inheritance may be a compile-time mechanism. A super-class will have any
number of subclasses. However a subclass will have just one super class. This is
because Java does not support multiple inheritances.

2.2 Aggregation
Aggregation is an extension of association mean aggregation is a strong
form of association within which an aggregate object is formed of components.
Components are a part of the aggregate. So aggregation is the “part-whole” or “a-
part-of” relationship.

Aggregation is a special case of association, a directional association


between objects. When an object „has-a‟ another object, then you have got an
aggregation between them. Direction between them specified that object contains
the other object. Aggregation is additionally known as a “Has-a” relationship.

Check your progress 1


1. What is Aggregation?
a. IS-A relationship

b. a-part-of relationship
c. Has-a relationship
d. Both B and C

18
2.3 Abstract Class Advance
Modeling
In Java, a class is a group of objects having certain common properties. It is Concepts
a sort of template or blueprint from where objects are created. So a class in java
contains:

 Data member

 Method

 Constructor

 Block

 Class and interface


The syntax to declare a class is:

Class <class_name>{
Data member;

method
}

Consider an example of Object and Class


In this example, a Student class is created having two data members‟ id and
name. Now the object of Student class is created with the help of new keyword
and printing objects value as:

If we run the above program, we find:

Output: 0 null

Abstract Class
An abstract class defines an abstract concept that can‟t be instantiated. we
can‟t create object of abstract class, it will only be inherited. Abstract class
19
Object normally represents concept with general actions associated with it. Abstract class
Oriented can‟t be instantiated; it will solely be inherited while interfaces should be
Modeling implemented. Abstract class will have implemented methods which interfaces will
have only definitions of the methods without implementation.

Fig 2.1 Abstract Class relationship

Check your progress 2


1. Abstract class are _____________.

a. Inherited
b. Implemented

c. Instantiated
d. None of these

2.4 Multiple Inheritance


Inheritance is the most important features of Object oriented Programming
that permits a {class|a category} to use properties and methods of another class. In
this, the derived class is named as subclass and base class is named as super-class.
It‟s seen that a derived class adds additional variables and methods which can
differentiate derived class from base class. The syntax is shown below:

20
Consider an example: Advance
Modeling
Concepts

If we run the above program, we get:

21
Object Inheritance results as an effective method which will share code among
Oriented various classes having some traits in common by allowing classes to have
Modeling different parts. Fig 2.2 called as Vehicle class which carries two subclasses as Car
and Truck.

Fig 2.2 Vehicle class

It is seen that Vehicle class belongs to superclass of Car and Truck that are
subclasses of Vehicle. Here, the Vehicle class contain those fields and methods
which are Vehicles needed whereas Car and Truck have fields and methods
particular to Cars and Trucks.

It is seen that many people declare that inheritance is a way to categorize


particular class. It is studied that a Car is a Vehicle where a Truck is also a
Vehicle. So, it is not how you determine super classes and subclasses in your
application. It simply shows how you need to work with them.

As seen, when a subclass extends a super class, then all protected and public
fields and methods of it gets inherited by subclass. In this, the fields and methods
are part of subclass, as if subclass declared itself.
Multiple Inheritance is a technique where one class extends more than one
base class.

Fig 2.3 Multiple inheritance

The latter point is an advanced version of inheritance and is called multiple


inheritance. Multiple inheritance provides an alternative approach where the new

22
class can inherit information from the two relevant classes. This is shown in the Advance
figure 2.4. Modeling
Concepts

Fig 2.4 Multiple Inheritance

In the above figure we noticed some inconsistencies, where sloopy at the


bottom has wheels and wings that are inherited from rim sloopy and float sloopy.
In this, the boy is sloopy and not the girl and also wheels float sloopy inherited
attributes of boy and girl which appear to be a conflict.

Check your progress 3


1. Select the correct option if class A is inherited by class B.

a. class B + class A
b. class B inherits class A

c. class B extends A
d. class B extends class A

2.5 Generalization as an Extension


Generalization is a process of defining a super class from a given set of
semantically related entity set. Generalization is the process of extracting shared
characteristics from two or more classes, and combining them into a generalized
super class. Shared characteristics can be attributes, associations, or methods.
23
Object Generalization is the relationship between a class and one or more refined
Oriented versions of it. The class being refined is called the “superclass” and each refined
Modeling version is called a “subclass”. For example, Equipment is the superclass of Pump
and tank. Attributes and operations that are common to a group of subclasses are
attached to the superclass and shared by each subclass. Generalization is
sometimes called an “is-a” relationship. Each instance of a subclass is an instance
of the superclass.

Check your progress 4


1. What is generalization?
a. Relationship between one class and its refined versions

b. IS-A relationship
c. Defining super class from given set of related entities
d. All of these

2.6 Generalization as a Restriction


In generalization, an instance of a class is an instance of a class is an
instance of all ancestors of the class. Therefore you can say that all ancestor class
features must apply to the subclass instances. This includes not only the attributes
on the ancestor classes but also the operations on the ancestor class.
A subclass may include many features, which is called as an extension. For
example, fig.2.5 extends class Employee with three subclasses that inherit all
Employee features and add new features of their own.

24
Advance
Modeling
Concepts

Fig 2.5 Class Employee

A subclass may also constrain ancestor attributes. This is called restriction


because it restricts the values that instances can assume. For example, a circle is
an ellipse that‟s major and minor axes are equal. Arbitrary changes to the attribute
values of a restricted subclass may cause it to violate the constraints, such that the
result no longer belongs to the original subclass. This is not a problem from the
perspective of the super class because the result is still a valid super class instance.

Check your progress 5


1. What is meant by restriction in generalization?
a. Attribute

b. All ancestor class features must apply to the subclass instances, this is
known as restriction

c. Inherited features
d. None of these

2.7 Metadata
Metadata is called as data about data or data that describes about other data.
It is everywhere certainly where many data is useless without metadata as it is also
data. Metadata summarizes basic information about data, which can make finding
25
Object and working with particular instances of data easier. In addition to document files,
Oriented metadata is used for images, videos, spreadsheets and web pages. The use of
Modeling metadata on web pages can be very important. Metadata for web pages contain
descriptions of the page‟s contents, as well as keywords linked to the content.
These are usually expressed in the form of metatags. The metadata containing the
web page‟s description and summary is often displayed in search results by search
engines, making its accuracy and details very important since it can determine
whether a user decides to visit the site or not.

Check your progress 6


1. Which of the following is true about meta data?

a. It is the data that describes about other data


b. It summarizes basic information about data
c. It is expressed in the form of metatags

d. All of these

2.8 Constraints
A constraint could be a numeric or geometric relationship between objects.
Constraints have a declarative nature. Constraints are a natural manner for
describing relationships between objects. Combining constraint systems and
object-oriented programming (OOP) seems hard. All existing systems implicitly
compromise the encapsulation principle of OOP.

Constraints describe properties that have to be true at each moment in time


for the entire system, without determining however they're to be preserved. The
specification of constraints is mostly done by using informal text, operational
restrictions or integrating constraints in existing model ideas.

Constraints are a way to specific general properties for the system, without
specifying however they're being realized.

26
Advance
Check your progress 7
Modeling
1. What can constitute constraints? Concepts

a. Numeric data

b. Geometric relationship
c. Both of these

d. None of these

2.9 An Object Model


An object model is typically a logical interface, software or system that's
modelled through the utilization of object-oriented techniques. It permits the
creation of an architectural software or system model before development or
programming.
An object model is a component of the object-oriented programming (OOP)
lifecycle.

Following are the benefits of using the object model are:

 It helps in quicker development of software.

 It is straightforward to maintain. Suppose a module develops an error, then a


programmer will fix that specific module, whereas the other elements of the
software are still up and running.

 It supports relatively hassle-free upgrades.

 It enables reuse of objects, designs, and functions.

 It reduces development risks, significantly in integration of advanced


systems.

27
Object Check your progress 8
Oriented
Modeling 1. Why do there is a need to use object model?
a. It helps in faster development of software

b. reusability
c. reduces development risk

d. All of these

2.10 Let Us Sum Up


In this unit we have learnt that Inheritance can be defined as the process
where one object acquires the properties of another. These inheritances make the
information to manage in a hierarchical order. It is studied that a Subclass in Java
is a method of inheritance which appears from Java superclass.
There exist three types of variables in Java as Local, Instance and Static. It
is studied that local variable is a variable which is declared within method itself,
instance variable is a variable which is declared within class but outside method
and static variable is a variable which is declared as static is called static variable.

In Java, it is seen that constructor can be inherited as the constructor name is


based on class name. While inheriting methods, the method signature should
remain same.

2.11 Answers for Check Your Progress

Check your progress 1

Answers: (1 –d)

Check your progress 2

Answers: (1 –a)

Check your progress 3

Answers: (1 –c)

28
Check your progress 4 Advance
Modeling
Concepts
Answers: (1 –d)

Check your progress 5

Answers: (1 –b)

Check your progress 6

Answers: (1 –d)

Check your progress 7

Answers: (1 –c)

Check your progress 8

Answers: (1 –d)

2.12 Glossary
1. Static variable - It is a variable which is declared as static is called static
variable
2. Class - These are group of objects with common properties and are like a
blueprint from where objects are created.

2.13 Assignment
Write a short note on inheritance and its use.

2.14 Activities
Study abstract classes and its usage

2.15 Case Study


Discuss the output of this program?
29
Object
Oriented
Modeling

2.16 Further Readings


1. DOWLATSHAHI, S., 1992, Product design in a concurrent engineering
environment: an opti- mization approach, International Journal of
Production Research, 30(8), pp. 1803–1818.
2. ESCHENAUER, H., KOSKI, J. and OSYCZKA, A., 1990, Multicriteria
Design Optimization: Procedures and Applications (New York: Springer-
Verlag).

3. FENG, C. X. and KUSIAK, A., 1995, Constraint-based design of parts,


Computer-Aided Design, 27(5), pp. 343–352.

30
Block Summary
In this block, you will be detailed with knowledge about Inheritance and its
relationship with subclass and interface block. The concepts about types of
variables with illustrations are explained in step by step manner. The block stress
on information related to packages and interface with examples about inherit
abstract methods of interface. The information related to declaring a reference
variable of interface is well explained with examples.
After studying this block, you will feel self confident while working on
simple Java platform and can enhance their knowledge by studying certain
examples and illustrations mentioned in this block. With such detailed knowledge
on Inheritance, Interface, Packages and Exceptions in Java, you can be benefitted
in future.

31
Object Block Assignment
Oriented
Modeling Short Answer Questions
1. What is object oriented modeling?
2. Explain inheritance and its types

3. What is the difference between generalisation and specialisation?


4. Write short note on Abstract classes

Long Answer Questions


1. What is multiple inheritance. Explain in detail with the help of an example

2. Write short note on metadata.


3. Write note on generalisation as a restriction

32
Enrolment No.
1. How many hours did you need for studying the units?

Unit No 1 2 3 4

Nos of Hrs

2. Please give your reactions to the following items based on your reading of the
block:

3. Any Other Comments


………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

………………………………………………………………………………………………

33
Education is something
which ought to be
brought within
the reach of every one.

- Dr. B. R. Ambedkar

Dr. Babasaheb Ambedkar Open University


‘Jyotirmay Parisar’, Opp. Shri Balaji Temple, Sarkhej-Gandhinagar Highway, Chharodi,
Ahmedabad-382 481.

You might also like