SlideShare a Scribd company logo
Object Oriented
Concept
Part 2
Aggregation & Composition
Aggregation vs. Composition
Inheritance
Composition vs. Inheritance Presented by Nuzhat Ibrahim Memon
Presented by Nuzhat Ibrahim Memon
2
Name
• first name: String
• last name: string
• display()
Person
• nm: Name
• addr:Address
• birthdate:date
• setbirthdate(d:int, m:int,
y:int):date
Address
•house: string
•street:string
•state:string
•pincode:int
•fulladress(): string
Teacher
• Subject : string
• lecture(d:date, t:time)
• When objects of one class are composed of objects of
other class, it is called aggregation or composition.
• It represents “has-a” or “a-part-of” relationship
between classes.
Presented by Nuzhat Ibrahim Memon
3
Person
• nm: Name
• addr: Address
• birthdate:date
• setbirthdate(d:int, m:int,
y:int):date
• display()
Name
• First Name: string
• Middle name:string
• last name:string
• fullName():string
• display()
Address
• house: string
• street:string
• state:string
• pincode:int
• fulladress(): string
• display()
Screen
• length: int
• width: int
• model: string
Motherboard
• model: string
• company: string
computer
• scr: Screen
• mb: Motherboard
• Take an example of ‘person’ class
• We will define two classed ‘Name’ and ‘Address’.
• Class ‘Name’ has an attribute first name, middle
name and last name.
• Class ‘address’ has an attribute house, street, city,
state and pincode.
• The data type of attributes ‘nm’ and ‘addr’ is class
‘Name’ and ‘Address’ respectively.
• Thus class ‘person’ contains object of class ‘Name’
and ‘Address’
• Aggregation represents non-exclusive relationship between two
classes.
• In aggregation, the class that forms part of the owner class can exist
independently.
• The life of an object of the part class is not determined by the owner
class.
• Object Address may be shared by more than one person. Address is
not exclusive to any one person. So, when a person is deleted, the
corresponding address cannot be deleted.
• Basic aggregation is represented using an empty diamond symbol
next to the whole class.
• Composition represents exclusive relationship between two classes.
• Composition is a strong type of aggregation where the lifetime of the
class depends on the existence of the owner class.
• If an object of aggregating class is deleted, its part class object also
will get deleted. For eg. When an object of class person is deleted, the
object of class name is also deleted. Name is associated exclusively
with single person.
• Composition relationships are represented using a filled diamond
next to the whole class.
Owner class,
Whole class or
aggregating class
Presented by Nuzhat Ibrahim Memon
4
Name
• first name: string
• Middle name: string
• last name: string
• display()
Person
• nm: Name
• addr:Address
• birthdate:date
• setbirthdate(d:int,
m:int, y:int):date
Address
•house: string
•street:string
•state:string
•pincode:int
•fulladress(): string
Subject class,
part class or
aggregated class
Subject class,
part class or
aggregated class
Composition Relationship
(Filled diamond)
Aggregation Relationship
(Empty diamond)
• Inheritance is generally referred to as ‘is-a-kind-of’ relationship
between two classes.
• Inheritance is appropriate when one class is ‘a kind of’ other
class. For e.g. teacher is a kind of person. So, all the attributes
and methods of class ‘Person’ are applicable to class ‘Teacher’
also.
• Inheritance refers to the capability of defining a new class of
objects that inherits the characteristic of another existing class.
• In other words, class ‘Teacher’ inherits all attributes and
behavior of class ‘Person’. Class ‘Teacher’ may have additional
attributes like subject and method like taking lectures of the
subject. In such scenario, class ‘Teacher’ can be defined using
class ‘Person’.
• The feature provides reusability where existing methods can be
reused without redefining. In other words, the data attributes
and methods of the super class are available to objects in the
sub class without rewriting their declarations.
Presented by Nuzhat Ibrahim Memon
5
Person
• name:string
• city: string
• gender:char=‘F’
• setBirthdate(d:int, m:int, y:int):date
• display()
Teacher
• subject: string
• lecture (d:date, t:time)
Existing class is called New Class is called
super class sub class
parent class child class
base class derived class
In Class Diagram, Inheritance is represented using
an arrow pointing to super class.
Presented by Nuzhat Ibrahim Memon
6
• Generalization is another name for inheritance or “is a” relationship.
• It refers to a relationship between two classes where one class is a specialized
version of another.
• Common attributes and methods are defined in super class.
• Sub class is a specialized version with additional attributes and methods.
• There may be a classical hierarchy of inheritance between classes. For e.g. class
‘Employee’ can be derived from class ‘Person’, then class ‘Teacher’ can be derived
from ‘Employee’. Here employee is a kind of person and teacher is a kind of
employee. Such type of inheritance is known as multilevel inheritance.
• A class can also be derived using more than parent classes. For e.g. a child inherits
the characteristics of both mother and father. When a class is derived from two or
more classes. It is known as multiple inheritance. In multiple inheritance, child will
get properties from father as well as mother from both the parents.
• Example: airplane is a kind of vehicle as well as flying object.
Person
Teacher
Employee
Child
Father Mother
Airplane
Vehicle
Flying
object
Person
(Super Class)
Teacher
(Sub Class)
Common attributes & methods
Additional attributes & methods
Grandfather
Son
Father
• In inheritance, class inherits from other classes
in order to share, reuse or extend functionality.
Here there exists ‘is a’ or ‘a kind of’ relationship
between super class and sub class.
• In composition, classes do not inherit from other
classes, but are ‘composed of’ other classes.
Class contains the attributes where some
attributes are of objects of other class types.
Presented by Nuzhat Ibrahim Memon
7
Social
Networking Site
Facebook Users
is a
has a
Nuzhat Memon
website:
nuzhatmemon.com
Email:
nuzhat.memon@gmail.com

More Related Content

What's hot

Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
RubaNagarajan
 
Java.util
Java.utilJava.util
Java.util
Ramakrishna kapa
 
Interface in java
Interface in javaInterface in java
Interface in java
PhD Research Scholar
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
Sehwan Noh
 
OOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and ObjectOOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and Object
dkpawar
 
Class or Object
Class or ObjectClass or Object
Class or Object
Rahul Bathri
 
Projection Matrices
Projection MatricesProjection Matrices
Projection Matrices
Syed Zaid Irshad
 
07 java variables
07   java variables07   java variables
07 java variables
Zeeshan-Shaikh
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
malathip12
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
Atul Sehdev
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Core java
Core javaCore java
Core java
Shivaraj R
 
Java string handling
Java string handlingJava string handling
Java string handling
Salman Khan
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Nuzhat Memon
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
saikat rahman
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Hitesh Kumar
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
Abhishek Wadhwa
 
Interface
InterfaceInterface
Interface
kamal kotecha
 

What's hot (20)

Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 
Java.util
Java.utilJava.util
Java.util
 
Interface in java
Interface in javaInterface in java
Interface in java
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
OOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and ObjectOOP Unit 2 - Classes and Object
OOP Unit 2 - Classes and Object
 
Class or Object
Class or ObjectClass or Object
Class or Object
 
Projection Matrices
Projection MatricesProjection Matrices
Projection Matrices
 
07 java variables
07   java variables07   java variables
07 java variables
 
Java interface
Java interfaceJava interface
Java interface
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Core java
Core javaCore java
Core java
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
Friend function & friend class
Friend function & friend classFriend function & friend class
Friend function & friend class
 
Interface
InterfaceInterface
Interface
 

More from Nuzhat Memon

Std 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQsStd 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQs
Nuzhat Memon
 
Std 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQsStd 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQs
Nuzhat Memon
 
Std 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQsStd 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQs
Nuzhat Memon
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQs
Nuzhat Memon
 
Std 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqsStd 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqs
Nuzhat Memon
 
Std 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structureStd 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structure
Nuzhat Memon
 
Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)
Nuzhat Memon
 
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQsStd 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Nuzhat Memon
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
Nuzhat Memon
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)
Nuzhat Memon
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
Nuzhat Memon
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
Nuzhat Memon
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Nuzhat Memon
 
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Nuzhat Memon
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Nuzhat Memon
 
Std 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to LayersStd 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to Layers
Nuzhat Memon
 
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...
Nuzhat Memon
 
Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)
Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)
Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)
Nuzhat Memon
 

More from Nuzhat Memon (20)

Std 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQsStd 10 chapter 11 data type, expression and operators important MCQs
Std 10 chapter 11 data type, expression and operators important MCQs
 
Std 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQsStd 10 Chapter 10 Introduction to C Language Important MCQs
Std 10 Chapter 10 Introduction to C Language Important MCQs
 
Std 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQsStd 12 chapter 7 Java Basics Important MCQs
Std 12 chapter 7 Java Basics Important MCQs
 
Std 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQsStd 12 computer chapter 8 classes and objects in java important MCQs
Std 12 computer chapter 8 classes and objects in java important MCQs
 
Std 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqsStd 12 Computer Chapter 6 object oriented concept important mcqs
Std 12 Computer Chapter 6 object oriented concept important mcqs
 
Std 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structureStd 12 computer java basics part 3 control structure
Std 12 computer java basics part 3 control structure
 
Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)Std 12 Computer Chapter 7 Java Basics (Part 2)
Std 12 Computer Chapter 7 Java Basics (Part 2)
 
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQsStd 12 Computer Chapter 13 other useful free tools and services important MCQs
Std 12 Computer Chapter 13 other useful free tools and services important MCQs
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
 
Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)Std 10 computer chapter 10 introduction to c language (part2)
Std 10 computer chapter 10 introduction to c language (part2)
 
Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)Std 10 computer chapter 10 introduction to c language (part1)
Std 10 computer chapter 10 introduction to c language (part1)
 
Std 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem SolvingStd 10 computer chapter 9 Problems and Problem Solving
Std 10 computer chapter 9 Problems and Problem Solving
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 3: Masking to R...
 
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
Chapter 5 Using Pictures in Synfig (Practical 2: Masking to hide area in synfig)
 
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1  Basics Opera...
Std 11 Computer Chapter 5 Using Pictures in Synfig (Practical 1 Basics Opera...
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...Std 11 Computer Chapter 4 Introduction to Layers  (Part 3 Solving Textual Exe...
Std 11 Computer Chapter 4 Introduction to Layers (Part 3 Solving Textual Exe...
 
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
Std 11 Computer Chapter 4 Introduction to Layers (Part 2 Practical :Rotation ...
 
Std 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to LayersStd 11 Computer Chapter 4 Introduction to Layers
Std 11 Computer Chapter 4 Introduction to Layers
 
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...Std 11 Computer Chapter 3  Creating Animation using Synfig (Part 3) [practica...
Std 11 Computer Chapter 3 Creating Animation using Synfig (Part 3) [practica...
 
Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)
Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)
Std 11 Computer Chapter 3 Creating Animation using Synfig (part 1)
 

Recently uploaded

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
datarid22
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 

Recently uploaded (20)

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
kitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptxkitab khulasah nurul yaqin jilid 1 - 2.pptx
kitab khulasah nurul yaqin jilid 1 - 2.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 

Std 12 computer chapter 6 object oriented concepts (part 2)

  • 1. Object Oriented Concept Part 2 Aggregation & Composition Aggregation vs. Composition Inheritance Composition vs. Inheritance Presented by Nuzhat Ibrahim Memon
  • 2. Presented by Nuzhat Ibrahim Memon 2 Name • first name: String • last name: string • display() Person • nm: Name • addr:Address • birthdate:date • setbirthdate(d:int, m:int, y:int):date Address •house: string •street:string •state:string •pincode:int •fulladress(): string Teacher • Subject : string • lecture(d:date, t:time)
  • 3. • When objects of one class are composed of objects of other class, it is called aggregation or composition. • It represents “has-a” or “a-part-of” relationship between classes. Presented by Nuzhat Ibrahim Memon 3 Person • nm: Name • addr: Address • birthdate:date • setbirthdate(d:int, m:int, y:int):date • display() Name • First Name: string • Middle name:string • last name:string • fullName():string • display() Address • house: string • street:string • state:string • pincode:int • fulladress(): string • display() Screen • length: int • width: int • model: string Motherboard • model: string • company: string computer • scr: Screen • mb: Motherboard • Take an example of ‘person’ class • We will define two classed ‘Name’ and ‘Address’. • Class ‘Name’ has an attribute first name, middle name and last name. • Class ‘address’ has an attribute house, street, city, state and pincode. • The data type of attributes ‘nm’ and ‘addr’ is class ‘Name’ and ‘Address’ respectively. • Thus class ‘person’ contains object of class ‘Name’ and ‘Address’
  • 4. • Aggregation represents non-exclusive relationship between two classes. • In aggregation, the class that forms part of the owner class can exist independently. • The life of an object of the part class is not determined by the owner class. • Object Address may be shared by more than one person. Address is not exclusive to any one person. So, when a person is deleted, the corresponding address cannot be deleted. • Basic aggregation is represented using an empty diamond symbol next to the whole class. • Composition represents exclusive relationship between two classes. • Composition is a strong type of aggregation where the lifetime of the class depends on the existence of the owner class. • If an object of aggregating class is deleted, its part class object also will get deleted. For eg. When an object of class person is deleted, the object of class name is also deleted. Name is associated exclusively with single person. • Composition relationships are represented using a filled diamond next to the whole class. Owner class, Whole class or aggregating class Presented by Nuzhat Ibrahim Memon 4 Name • first name: string • Middle name: string • last name: string • display() Person • nm: Name • addr:Address • birthdate:date • setbirthdate(d:int, m:int, y:int):date Address •house: string •street:string •state:string •pincode:int •fulladress(): string Subject class, part class or aggregated class Subject class, part class or aggregated class Composition Relationship (Filled diamond) Aggregation Relationship (Empty diamond)
  • 5. • Inheritance is generally referred to as ‘is-a-kind-of’ relationship between two classes. • Inheritance is appropriate when one class is ‘a kind of’ other class. For e.g. teacher is a kind of person. So, all the attributes and methods of class ‘Person’ are applicable to class ‘Teacher’ also. • Inheritance refers to the capability of defining a new class of objects that inherits the characteristic of another existing class. • In other words, class ‘Teacher’ inherits all attributes and behavior of class ‘Person’. Class ‘Teacher’ may have additional attributes like subject and method like taking lectures of the subject. In such scenario, class ‘Teacher’ can be defined using class ‘Person’. • The feature provides reusability where existing methods can be reused without redefining. In other words, the data attributes and methods of the super class are available to objects in the sub class without rewriting their declarations. Presented by Nuzhat Ibrahim Memon 5 Person • name:string • city: string • gender:char=‘F’ • setBirthdate(d:int, m:int, y:int):date • display() Teacher • subject: string • lecture (d:date, t:time) Existing class is called New Class is called super class sub class parent class child class base class derived class In Class Diagram, Inheritance is represented using an arrow pointing to super class.
  • 6. Presented by Nuzhat Ibrahim Memon 6 • Generalization is another name for inheritance or “is a” relationship. • It refers to a relationship between two classes where one class is a specialized version of another. • Common attributes and methods are defined in super class. • Sub class is a specialized version with additional attributes and methods. • There may be a classical hierarchy of inheritance between classes. For e.g. class ‘Employee’ can be derived from class ‘Person’, then class ‘Teacher’ can be derived from ‘Employee’. Here employee is a kind of person and teacher is a kind of employee. Such type of inheritance is known as multilevel inheritance. • A class can also be derived using more than parent classes. For e.g. a child inherits the characteristics of both mother and father. When a class is derived from two or more classes. It is known as multiple inheritance. In multiple inheritance, child will get properties from father as well as mother from both the parents. • Example: airplane is a kind of vehicle as well as flying object. Person Teacher Employee Child Father Mother Airplane Vehicle Flying object Person (Super Class) Teacher (Sub Class) Common attributes & methods Additional attributes & methods Grandfather Son Father
  • 7. • In inheritance, class inherits from other classes in order to share, reuse or extend functionality. Here there exists ‘is a’ or ‘a kind of’ relationship between super class and sub class. • In composition, classes do not inherit from other classes, but are ‘composed of’ other classes. Class contains the attributes where some attributes are of objects of other class types. Presented by Nuzhat Ibrahim Memon 7 Social Networking Site Facebook Users is a has a