Oop 2
Oop 2
Part 2
Outline
▰ OOP Pillars
2
Introduction
3
Introduction
4
5
Benefits of OOP
6
Challenges of OOP
7
Encapsulation
8
Encapsulation
9
Encapsulation
11
Inheritance
13
Inheritance
14
Inheritance - 5 types
▰ Single
▰ Multi level
▰ Hierarchical
▰ Multiple
▰ Hybrid
15
Inheritance - 5 Types
1. Single Inheritance
In single inheritance, one class
inherits the properties of another. It
enables a derived class to inherit
the properties and behavior from a
single parent class. This will in turn
enable code reusability as well as
add new features to the existing
code.
16
Inheritance - 5 Types
1. Single Inheritance
In single inheritance, one class
inherits the properties of another.
It enables a derived class to inherit
the properties and behavior from a
single parent class. This will in turn
enable code reusability as well as
add new features to the existing
code.
17
Inheritance - 5 Types
1. Single Inheritance
In single inheritance, one class
inherits the properties of another.
It enables a derived class to inherit
the properties and behavior from a
single parent class. This will in turn
enable code reusability as well as
add new features to the existing
code.
18
Inheritance - 5 Types
21
Inheritance - 5 Types
3. Hierarchical Inheritance
When a class has more than one
child classes (sub classes) or in
other words, more than one child
classes have the same parent
class, then such kind of
inheritance is known as
hierarchical.
22
Inheritance - 5 Types
3. Hierarchical Inheritance
When a class has more than one
child classes (sub classes) or in
other words, more than one child
classes have the same parent
class, then such kind of
inheritance is known as
hierarchical.
23
Inheritance - 5 Types
3. Hierarchical Inheritance
When a class has more than one
child classes (sub classes) or in
other words, more than one child
classes have the same parent
class, then such kind of
inheritance is known as
hierarchical.
24
Inheritance - 5 Types
25
Inheritance - 5 Types
4. Multiple Inheritance
Multiple inheritances is a type of
inheritance where a subclass can
inherit features from more than
one parent class.
26
Inheritance - 5 Types
5. Hybrid Inheritance
Hybrid inheritance is a
combination of multiple inheritance
and multilevel inheritance. Since
multiple inheritance is not
supported in Java as it leads to
ambiguity, so this type of
inheritance can only be achieved
through the use of the interfaces.
27
OOP: Abstraction
28
OOP: Abstraction
29
OOP: Abstraction
30
OOP: Abstraction
31
OOP: Abstraction
32
OOP: Abstraction
33
OOP: Abstraction
34
OOP: Abstraction
35
OOP: Abstraction
36
OOP: Abstraction
37
OOP: Abstraction
39
OOP: Polymorphism
40
OOP: Polymorphism
41
OOP: Polymorphism
42
OOP: Polymorphism
43
OOP: Polymorphism
44
OOP: Polymorphism
45
OOP: Polymorphism
47