
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Constructor Functions in Subclasses
|
193
• The parameters of both methods must have the same datatypes. (ActionScript 2.0
developers must sometimes ignore this rule; see the later explanation.)
• Both methods must have the same return type.
• The overriding method must be at least as accessible as the overridden method
(that is, the overriding method can’t be private if the overridden method is
public).
In Java, an instance property can override an instance property or a class property.
The reverse is also true—a class property can override an instance property or a class
property. However, as noted earlier, it’s clearest to override instance properties only
with other instance properties and class properties only with other class properties.
Table 6-5 summarizes Java’s member overriding rules. When programming in
ActionScript, it’s wise to follow them, with one exception: in ActionScript, it is legiti-
mate to change the number, datatype(s), and order of parameters for a method when
overriding it. The method doing the overriding might need to offer different parame-
ters in order to handle a specialized situation. In Java, defining a subclass method
with the same name as a superclass method, but with a different number,
datatype(s), or order of parameters constitutes a method overload ...