Chapter 11
Chapter 11
Exploring polymorphism
6.0
Main concepts to be covered
• method polymorphism
• static and dynamic type
• overriding
• dynamic method lookup
• protected access
Leonardo da Vinci
40 seconds ago - 2 people like this.
No comments.
What we have
Alexander Graham Bell
12 minutes ago - 4 people like this.
No comments.
display method
in both super-
and subclasses.
Satisfies both
static and
dynamic type
checking.
No inheritance or polymorphism.
The obvious method is selected.
Inheritance but no
overriding. The inheritance
hierarchy is ascended,
searching for a match.
© 2017 Pearson Education, Inc. Hoboken, NJ. All rights reserved. 14
Method lookup
Polymorphism and
overriding. The ‘first’
version found is used.
System.out.println(post);