Using diagrams to explain what is really going on in Java Inheritance/Polymorphism
What you will learn
Inheritance
Overriding
Polymorphism
Upcasting/Downcasting
Data hiding
Covariant Returns
Exception signatures when overriding methods
Reference type determining accessible methods
ClassCastExceptions
Overloading
Description
This is one category (of eleven) from my systematic preparation course for the 1Z0-808 Oracle Java SE 8 Programmer 1 (OCA) exam which I have delivered several times; both in person and online.
This Inheritance course is not a notes-based course. As the Oracle exam is based on multiple choice questions (MCQ), this course focuses completely on MCQ using the excellent Enthuware tool. In fact, Enthuware supplement their explanations by referring to my online explanations.
In this course, I answer 20 random questions from Enthuware’s Inheritance category and use diagrams and code where needed. The diagrams in particular are extremely helpful when explaining Inheritance-related concepts. For example, a UML diagram helps greatly with explaining why a reference of type Car cannot refer to an object of type Vehicle. The other type of diagram I use frequently is the in-memory representation of references referring to objects. Separating these two concepts (references and objects) is critical to answering many MCQ-style questions.
While the course is ideal for those preparing for the 1Z0-808 exam, the topics discussed will benefit anyone trying to understand Inheritance at a deeper level. For example, the following topics are all covered:
- method overriding
- polymorphism
- covariant returns
- where the parent method throws exceptions
- method overloading
- upcasting and downcasting
- shadowing – both methods and data
- the reference type determines the methods accessible
- the default modifiers applied to interface data
- the types of methods allowed in interfaces
- why an abstract class can implement an interface without implementing any of the interfaces’ methods
- ClassCastExceptions
Content