O'Reilly logo

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition by Ivor Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required