SlideShare a Scribd company logo
 Inheritance is one of the cornerstones of OOP because it allows for the creation
of hierarchical classifications
 Using inheritance, you can create a general class at the top
 This class may then be inherited by other, more specific classes
 Each of these classes will add only those attributes and behaviors that are unique to it
Inheritance
 In keeping with Java terminology, a class that is inherited is referred to as a superclass
 The class that does the inheriting is referred to as the subclass
 Each instance of a subclass includes all the members of the superclass
 The subclass inherits all the properties of its superclass
Generalization/ Specialization
 These terms are used to signify the relationship between classes
 They are the basic building blocks of OOPS
© 2017 wipro.co confidentia 3
Association, Aggregation, Composition
 Association is a relationship between two objects
 The association between objects could be
 one-to-one
 one-to-many
 many-to-one
 many-to-many
 Types of Association
 Aggregation
 Composition
 Example: A Student and a Faculty are having an association
Association
 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
 Aggregation is also called a “Has-a” relationship.
 Example: College has a Student Object
Aggregation
Composition
• Composition is a special case of aggregation
• In a more specific manner, a restricted aggregation is called composition
• When an object contains the other object, if the contained object cannot exist without the
existence of container object, then it is called composition
• Example: A class contains students. A student cannot exist without a class. There exists
composition between class and students
 HAS-A relationship is expressed with containership
 Containership simply means using instance variables that refer to other objects
 Example:
 The class House will have an instance variable which refers to a Kitchen object
 It means that, House HAS-A Kitchen
 Note that, something like Kitchen HAS-A House is not valid in this
context
HAS-A relationship
class A{
int money;
private int pocketMoney;
void fill(int money, int pocketMoney)
{
this.money = money;
this.pocketMoney = pocketMoney;
}
public int getPocketMoney(){
return pocketMoney;
}
}
A Possible Solution To The Program

More Related Content

Similar to Inheritance.pptxci-Net.ci-Netci-Net.ci-Net..ci-Net. (20)

PPTX
OOAD notes.pptx
RAJESH S
 
PPTX
OOAD.pptx
RAJESH S
 
PPTX
LN 1 Object Oriented Analysis Design notes.pptx
rajesshs31r
 
PPTX
Interdisciplinary integration
leakaszas
 
PPTX
Cognitive Processes - Facilitating Learning.pptx
AprilVias
 
PPTX
Difference between association, aggregation and composition
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Lesson one 1 OOAD study/ref material.pptx
rajesshs31r
 
PPTX
Inheritance in C++ (Programming Fundamentals)
Home
 
PPT
Unit 3 Java
arnold 7490
 
PPTX
This is a powerpoint presentation on the lesson about conjunctions and connec...
IrisEliseo
 
PPTX
Advance orgniser model
Ani Vadakke Purayil Kannur
 
PPTX
OO relationships between classes
Sujit Kumar
 
PPTX
7c77c32dc243f1956615a2eddbbb35603d1.pptx
Shwetamaurya36
 
PDF
Inheritance and Substitution
adil raja
 
PPTX
CLASS DIAGRAMS IN OBJECT ORIENTED ANALYSIS AND DESIGN
UmmuAhmed3
 
PPTX
Intro To Oer
Michigan State University
 
PPTX
java part 1 computer science.pptx
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
PPTX
Java(inheritance)
Pooja Bhojwani
 
PPS
The Culture of Content Sharing and Learning Objects
Lisa Johnson, PhD
 
OOAD notes.pptx
RAJESH S
 
OOAD.pptx
RAJESH S
 
LN 1 Object Oriented Analysis Design notes.pptx
rajesshs31r
 
Interdisciplinary integration
leakaszas
 
Cognitive Processes - Facilitating Learning.pptx
AprilVias
 
Difference between association, aggregation and composition
baabtra.com - No. 1 supplier of quality freshers
 
Lesson one 1 OOAD study/ref material.pptx
rajesshs31r
 
Inheritance in C++ (Programming Fundamentals)
Home
 
Unit 3 Java
arnold 7490
 
This is a powerpoint presentation on the lesson about conjunctions and connec...
IrisEliseo
 
Advance orgniser model
Ani Vadakke Purayil Kannur
 
OO relationships between classes
Sujit Kumar
 
7c77c32dc243f1956615a2eddbbb35603d1.pptx
Shwetamaurya36
 
Inheritance and Substitution
adil raja
 
CLASS DIAGRAMS IN OBJECT ORIENTED ANALYSIS AND DESIGN
UmmuAhmed3
 
java part 1 computer science.pptx
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Java(inheritance)
Pooja Bhojwani
 
The Culture of Content Sharing and Learning Objects
Lisa Johnson, PhD
 

Recently uploaded (20)

PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Thermal runway and thermal stability.pptx
godow93766
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Evaluation and thermal analysis of shell and tube heat exchanger as per requi...
shahveer210504
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Ad

Inheritance.pptxci-Net.ci-Netci-Net.ci-Net..ci-Net.

  • 1.  Inheritance is one of the cornerstones of OOP because it allows for the creation of hierarchical classifications  Using inheritance, you can create a general class at the top  This class may then be inherited by other, more specific classes  Each of these classes will add only those attributes and behaviors that are unique to it Inheritance
  • 2.  In keeping with Java terminology, a class that is inherited is referred to as a superclass  The class that does the inheriting is referred to as the subclass  Each instance of a subclass includes all the members of the superclass  The subclass inherits all the properties of its superclass Generalization/ Specialization
  • 3.  These terms are used to signify the relationship between classes  They are the basic building blocks of OOPS © 2017 wipro.co confidentia 3 Association, Aggregation, Composition
  • 4.  Association is a relationship between two objects  The association between objects could be  one-to-one  one-to-many  many-to-one  many-to-many  Types of Association  Aggregation  Composition  Example: A Student and a Faculty are having an association Association
  • 5.  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  Aggregation is also called a “Has-a” relationship.  Example: College has a Student Object Aggregation
  • 6. Composition • Composition is a special case of aggregation • In a more specific manner, a restricted aggregation is called composition • When an object contains the other object, if the contained object cannot exist without the existence of container object, then it is called composition • Example: A class contains students. A student cannot exist without a class. There exists composition between class and students
  • 7.  HAS-A relationship is expressed with containership  Containership simply means using instance variables that refer to other objects  Example:  The class House will have an instance variable which refers to a Kitchen object  It means that, House HAS-A Kitchen  Note that, something like Kitchen HAS-A House is not valid in this context HAS-A relationship
  • 8. class A{ int money; private int pocketMoney; void fill(int money, int pocketMoney) { this.money = money; this.pocketMoney = pocketMoney; } public int getPocketMoney(){ return pocketMoney; } } A Possible Solution To The Program