Understanding Inheritance

One of the biggest advantages to using object-oriented programming is inheritance, which is the way one object can inherit behavior and attributes from other objects that are similar to it.

When you start creating objects for use in other programs, you will find that some new objects you want are a lot like other objects that already have been developed. For example, if David Lightman does not run afoul of the law because of his ATM scheme, he might want to create an object that can handle error correction and other advanced modem features that weren't around back in 1983 when War Games was released.

Lightman could create a new ErrorCorrectionModem object by copying the statements of the Modem object and revising them. ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH 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.