Java Reference
In-Depth Information
change the part of the contract you inherit from the class you extended.
Changing the way that the superclass's contract is implemented is reas-
onable, but you should never change the implementation in a way that
violates that contract.
The ability to extend classes interacts with the access control mechan-
isms to expand the notion of contract that a class presents. Each class
can present two different contractsone for users of the class and one
for extenders of the class. Both of these contracts must be carefully de-
signed.
With class extension, inheritance of contract and inheritance of imple-
mentation always occur together. However, you can define new types
independent of implementation by using interfaces. You can also re-
use existing implementations, without affecting type, by manually using
composition and forwarding. Interfaces and composition are discussed
in Chapter 4 .
Class extension that involves generic classes has its own special rules
concerning redefining members, overriding, and overloading. These
rules are discussed in detail in Chapter 11 . In this chapter, generic types
are not considered.
 
Search WWH ::




Custom Search