Chapter 8. More OOP—Extending Classes

  • Inheritance

  • Polymorphism

  • The Class Whose Name Is Class

  • Exercises

  • Some Light Relief—The Nerd Detection System

We now come to the main part of object-oriented programming, covering inheritance and polymorphism. Despite the unusual names, they describe some clean concepts. You need a solid understanding of inheritance and polymorphism to program in an object-oriented language and to use some of the Java library routines.

As we have seen several times, inheritance means basing a new class on a class that is already defined. The new class will extend the existing class in some way. Just as inheritance in real life is “what you get from a parent,” inheritance in OOP is “what you get from a parent ...

Get Just Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.