tailieunhanh - Introduction to java programming: Chapter 9 - Inheritance and Polymorphism

Introduction to java programming: Chapter 9 - Inheritance and Polymorphism's Objectives is to develop a subclass from a superclass through inheritance; invoke the superclass’s constructors and methods using the super keyword; override methods in the subclass; distinguish differences between overriding and overloading. | Chapter 9 Inheritance and Polymorphism Liang Introduction to Java Programming Sixth Edition c 2005 Pearson Education Inc. All rights reserved. 0-13-148952-6 1 Objectives To develop a subclass from a superclass through inheritance . To invoke the superclass s constructors and methods using the super keyword . To override methods in the subclass . To distinguish differences between overriding and overloading . To explore the useful methods equals Object hashCode toString fìnalize clone and getClass in the Object class optional . To comprehend polymorphism dynamic binding and generic programming . To describe casting and explain why explicit downcasting is necessary . To store retrieve and manipulates objects in an ArrayList . To implement a Stack class using ArrayList . To restrict access to data and methods using the protected visibility modifier . To declare constants unmodifiable methods and nonextendable classes using the final modifier . Optional To understand the effect of hiding data fields and static methods . Optional To initialize data using initialization blocks and to distinguish between instance initialization and static initialization blocks . Optional GUI To use inheritance in GUI programming . Liang Introduction to Java Programming Sixth Edition c 2005 Pearson Education Inc. All 2 rights reserved. 0-13-148952-6 2 Superclasses and Subclasses GeometricObject -color String -filled boolean -dateCreated The color of the object default white . Indicates whether the object is filled with a color default false . The date when the object was created. GeometricObj ect getColor String setColor color String void isFilled boolean setFilled filled boolean void getDateCreated toString String Creates a GeometricObject. Returns the color. Sets a new color. Returns the filled property. Sets a new filled property. Returns the dateCreated. Returns a string representation of .