Inheritance & Polymorphism

After reading this chapter and engaging in the embedded activities and reflections, you should be able to:

  • Define inheritance and polymorphism and identify them in Java source code.
  • Use inheritance to design simple class hierarchies that allows code to be reused for distinct sub-classes.
  • Explain the relationship between inheritance and type substitution (the idea of a subtype being usable in a context that expects the super-type).
  • Identify apparent and actual types of objects and explain the relationship between them.
  • Express how type casting works for objects, and differentiate between "Upcasting" and "Downcasting."
  • Distinguish between single, multiple, and multi-level inheritance.
  • Explain the relationship between polymorphism and type substitution.
  • Distinguish between dynamic (runtime) and static (compile-time) polymorphism.
  • Describe how Java's method dispatch process works.
  • Develop examples of compile-time and runtime polymorphism.
  • Recognize inheritance must be used to model "is-a" relationship.
  • Contrast "is-a" to "has-a" relationships.
  • Arrange classes in a simple class diagram that exhibits "is-a"/"has-a" relationships.
  • Distinguish method overloading from method overriding.
  • Explain how every object in Java has a toString method.

Starter code for this chapter

Solution code

Solution code for this chapter.