Home Segments Top Top Previous Next

Chapter 19:

How to Enforce Requirements
Using Abstract Classes and Abstract Methods

Abstract classes are like ordinary classes in that they serve as collection points for variables and methods needed in subclasses. In contrast to an ordinary class, however, an abstract class allows you to declare methods without defining them. Such methods must be defined in any ordinary class that directly extends the abstract class.

In this chapter, you learn what abstract classes are and how they impose method-definition requirements. In this chapter and in Chapter 20, you learn that the ability to impose method-definition requirements plays an important role in promoting good programming practice.