- Size: 646.12 KB
- Uploaded: 2019-04-16 19:42:04
- Status: Successfully converted
10 Object-Oriented Programming: One Ring to rule them all, One Ring to ﬁnd them, One Ring to bring them all Polymorphism and in the darkness bind them. —John Ronald Reuel Tolkien General propositions do not decide concrete cases. OBJECTIVES —Oliver Wendell Holmes In this chapter you will learn: A philosopher of imposing stature doesn’t think in a ■ The concept of polymorphism. vacuum. Even his most ■ To use overridden methods to effect polymorphism. abstract ideas are, to some extent, conditioned by ■ To distinguish between abstract and concrete classes. what is or is not known in the time when he lives. ■ To declare abstract methods to create abstract classes. —Alfred North Whitehead ■ How polymorphism makes systems extensible and Why art thou cast down, maintainable. O my soul? ■ To determine an object’s type at execution time. —Psalms 42:5 ■ To declare and implement interfaces. © 2006 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Chapter 10 Object-Oriented Programming: Polymorphism 3 Assignment Checklist Name: Date: Section: Exercises Assigned: Circle assignments Date Due Prelab Activities Matching YES NO Fill in the Blank YES NO Short Answer YES NO Programming Output YES NO Correct the Code YES NO Lab Exercises Exercise 1 — Payroll System Modification YES NO Follow-Up Question and Activity 1 Exercise 2 — Accounts Payable System Modification YES NO Follow-Up Question and Activity 1 Debugging YES NO Labs Provided by Instructor 1. 2. 3. Postlab Activities Coding Exercises 1, 2, 3, 4, 5, 6, 7, 8 Programming Challenges 1, 2 © 2006 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Chapter 10 Object-Oriented Programming: Polymorphism 5 Prelab Activities Matching Name: Date: Section: After reading Chapter 10 of Java How to Program: Sixth Edition, answer the given questions. The questions are intended to test and reinforce your understanding of key concepts. You may answer the questions before or dur- ing the lab. For each term in the left column, write the letter for the description from the right column that best matches the term. Term Description 1. abstract method a) Can be used in place of an abstract class when there is no default 2. getClass method implementation to inherit. b) Indicates that a method cannot be overridden or that a class can- 3. implements keyword not be a superclass. 4. type-wrapper classes c) Class method which returns the name of the class associated with 5. downcasting the Class object. 6. concrete class d) An operator that returns true if its left operand (a variable of a ref- erence type) has the is-a relationship with its right operand (a class 7. polymorphism or interface name). 8. instanceof e) Uses superclass references to manipulate sets of subclass objects in 9. final a generic manner.