Web space - Chapter 9 Object-Oriented Programming 531 object-oriented programming (OOP)

Chapter 9 Object-Oriented Programming 531 object-oriented programming (OOP) subclass reference override a method super override an abstractmethod superclass overriding vs. overloading superclass constructor polymorphism superclass reference protected member of a class switchlogic reference to an abstract class this setSize method type-wrapper class setVisiblemethod uses a relationship single inheritance WindowAdapter class software reusability windowClosingmethod standardized software components WindowEvent class subclass WindowListener interface subclass constructor SELF-REVIEW EXERCISES 9.1 Fill in the blanks in each of the following statements: a) If the class Alphainherits from the class Beta, class Alpha is called the class and class Beta is called the class. b) Inheritance enables , which saves time in development and encourages using previously proven and high-quality software components. c) An object of a class can be treated as an object of its corresponding class. d) The four member access specifiers are , , and . e) A has a relationship between classes represents and an is a relationship between classes represents . f) Using polymorphism helps eliminate logic. g) If a class contains one or more abstract methods, it is an class. h) A method call resolved at run-time is referred to as binding. i) A subclass may call any nonprivate superclass method by prepending to the method call. 9.2 State whether each of the following statements is true or false. If false, explain why. a) A superclass typically represents a larger number of objects than its subclass represents (true/false). b) A subclass typically encapsulates less functionality than does its superclass. (true/false). ANSWERS TO SELF-REVIEW EXERCISES 9.1 a) sub, super. b) software reusability. c) sub, super. d) public, protected, privateand package access. e) composition, inheritance. f) switch. g) abstract. h) dynamic. i) super. 9.2 a) True. b) False. A subclass includes all the functionality of its superclass. EXERCISES 9.3 Consider the class Bicycle. Given your knowledge of some common components of bicycles, show a class hierarchy in which the class Bicycle inherits from other classes, which, in turn, inherit from yet other classes. Discuss the instantiation of various objects of class Bicycle. Discuss inheritance from class Bicyclefor other closely related subclasses. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/7/01

Leave a Reply