Chapter 6. Extending Classes and Inheritance

A very important part of object-oriented programming allows you to create a new class based on a class that has already been defined. The class that you use as the base for your new class can be one that you have defined, a standard class in Java, or a class defined by someone else—perhaps from a package supporting a specialized application area.

This chapter focuses on how you can reuse existing classes by creating new classes based on the ones you have and explores the ramifications of using this facility, and the additional capabilities it provides. You will also delve into an important related topic—interfaces—and how you can use them.

In this chapter you will learn:

  • How to reuse classes by defining a new class based on an existing class

  • What polymorphism is and how to define your classes to take advantage of it

  • What an abstract method is

  • What an abstract class is

  • What an interface is and how you can define your own interfaces

  • How to use interfaces in your classes

  • How interfaces can help you implement polymorphic classes

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th 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.