Chapter 12. Making the Most of Existing Objects

<feature><title></title>

WHAT YOU’LL LEARN IN THIS HOUR:

  • Designing superclasses and subclasses

  • Forming an inheritance hierarchy

  • Overriding methods

</feature>

Java objects are ideally suited for childbearing. When you create an object—a set of attributes and behavior—you have designed something that’s ready to pass these qualities on to offspring. These child objects take on a lot of the same attributes and behavior of their parent. They also can do some things differently than their parent.

This system is called inheritance, and it’s something every superclass (parent) gives to its subclasses (children). Inheritance is one of the most useful aspects of object-oriented programming (OOP), and you learn ...

Get Sams Teach Yourself Java™ in 24 Hours, Fifth Edition 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.