Site MapHelpFeedbackChapter Summary
Chapter Summary
(See related pages)

In this chapter, we will describe two important and powerful features in objectoriented programming—inheritance and polymorphism. The inheritance feature of object-oriented programming was introduced in Chapter 1. We will provide a more detailed explanation and examples of inheritance in this chapter.

The second major topic we cover in this chapter is polymorphism, another indispensable feature in object-oriented programming, which allows programmers to send the same message to objects from different classes. Consider the statement

account.computeMonthlyFee();

where account could be either a SavingsAccount or a CheckingAccount object. If account is a SavingsAccount object, then the method computeMonthlyFee defined for the SavingsAccount class is executed. Likewise, if account is a CheckingAccount object, then the method computeMonthlyFee defined for the CheckingAccount class is executed. Sending the same message therefore could result in executing different methods. The message computeMonthlyFee is called a polymorphic message because depending on the receiver object, different methods are executed. Polymorphism helps us write code that is easy to modify and extend. We will explain polymorphism in this chapter.







WuOnline Learning Center

Home > Chapter 13 > Chapter Summary