1Z0-808 (Java 8 OCA) : Java Inheritance and Polymorphism
Using diagrams to explain what is really going on in Java Inheritance/Polymorphism

What you will learn





Data hiding

Covariant Returns

Exception signatures when overriding methods

Reference type determining accessible methods




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.

Get Instant Notification of New Courses on our Telegram channel.

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





2.1291 – reference type determines the data you can access.
2.970 – diagrams discussing overriding, polymorphism, reference vs object type.
2.1086 – diagrams explaining covariant returns and reference vs. object types.
2.996 – the reference type determines the methods you can call (diagrams).
2.1150 – interface methods must be public and abstract (if no method body code).
2.1072 – ambiguous fields only become an issue if you use them.
2.1399 – getClass() returns the class of the object that the reference refers to
2.1320 – reference type determines the data accessed (static or non-static).
2.1056 – final classes cannot be subclassed.
2.1019 – overriding compared to overloading
2.1015 – trying to access private data defined higher up the inheritance tree.
2.1144 – interface fields are implicitly public, static and final.
2.1476 – recognizing valid interface methods.
2.1149 – assignments that fail to compile or generate ClassCastExceptions.
2.1481 – extending interfaces
2.931 – static methods cant be overridden by non-static methods (and vice versa)
2.900 – interfaces can extend from multiple interfaces.
2.1009 – a reference to a static field initialises the class that declares it.
2.1231 – abstract classes can implement interfaces without providing any methods
2.839 – overriding a method that defines an exception in its method signature.