


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of object-oriented programming (oop) concepts, focusing on inheritance, generalization, sub-typing, specialization, and overriding. It explains how classes can be related through inheritance, the benefits of inheritance, and the concepts of generalization, sub-typing, specialization, and overriding. Real-life examples are given to illustrate these concepts.
Typology: Slides
1 / 26
This page cannot be seen from the preview
Don't miss anything!



















Circle
colorverticesradiusmovesetColorcomputeArea
Line
colorverticeslengthmovesetColorgetLength
Triangle
colorverticesanglemovesetColorcomputeArea
Teacher
nameagegenderdesignationsalaryteachtakeExameatwalk
Student
nameagegenderprogramstudyYearstudyheldExameatwalk
Doctor
nameagegenderdesignationsalarycheckUpprescribeeat
Person
nameagegendereatwalk
Teacher
designationsalaryteach
Student
programstudyYearstudy
Doctor
designationsalarycheckUp
nameagegendereatswalks
programstudyYearstudy
Person
age : [0..100]…
Adult
age : [18..100]…
setAge( a )… setAge( a )
age = a
If age < 18 then
error
else
age = a
Provide behaviour specific to a derived class
Extend the default behaviour
Restrict the default behaviour
Improve performance
Shape
colorverticesdrawmovesetColor
Circle
radiusdraw
Line
length
Triangle
angledraw
IntegerSet
NaturalSet
add( elem )… add( elem )…
Add elementto the set If elem < 1 then
give error
else
Add elementto the set
Example – Improve Performance
►
Class Circle overridesrotate operation ofclass Shape with a Nulloperation.
Shape
colorcoorddrawrotatesetColor
Circle
radiusdraw