Upload
voquynh
View
220
Download
0
Embed Size (px)
Citation preview
1
1
York University – Department of Computer Science
Chapter 9Inheritance
I. Scott MacKenzie
2
York University – Department of Computer Science
Outline
2
3
York University – Department of Computer Science
What is Inheritance?
4
York University – Department of Computer Science
Terminology
3
5
York University – Department of Computer Science
Inheritance UML Diagrams (1)
6
York University – Department of Computer Science
Inheritance UML Diagrams (2)
4
7
York University – Department of Computer Science
Inheritance UML Diagrams (3)
8
York University – Department of Computer Science
Method Section of API
5
9
York University – Department of Computer Science
Methods in a Child Class
10
York University – Department of Computer Science
Child With Three Methods
6
11
York University – Department of Computer Science
RewardCard API
12
York University – Department of Computer Science
Inherited Fields
7
13
York University – Department of Computer Science
Fields in a Child Class
14
York University – Department of Computer Science
Child With Two Fields
8
15
York University – Department of Computer Science
Fields in RewardCard Class
16
York University – Department of Computer Science
Inheritance Chains
9
17
York University – Department of Computer Science
Polymorphism
18
York University – Department of Computer Science
instanceof Operator (1)
10
19
York University – Department of Computer Science
instanceof Operator (2)
20
York University – Department of Computer Science
instanceof Operator (3)
11
21
York University – Department of Computer Science
Manual Casts
22
York University – Department of Computer Science
Manual Cast Gotchas
12
23
York University – Department of Computer Science
Reference Resolution and Binding
341-342
24
York University – Department of Computer Science
Early and Late Binding
13
25
York University – Department of Computer Science
Reference Resolution
26
York University – Department of Computer Science
Abstract Classes
14
27
York University – Department of Computer Science
Abstract Classes (2)
28
York University – Department of Computer Science
Abstract Classes (3)
15
29
York University – Department of Computer Science
Abstract Classes (4)
30
York University – Department of Computer Science
Interfaces
16
31
York University – Department of Computer Science
Interfaces (2)
32
York University – Department of Computer Science
Disparate Hierarchies
17
33
York University – Department of Computer Science
Object Class
34
York University – Department of Computer Science
Object Class Methods
• Class getClass()• boolean equals(Object other)• String toString()• See API
18
35
York University – Department of Computer Science
Thank You