Java Reference
In-Depth Information
void fill(Color c);
}
interface GraphicalCardDealer
extends CardDealer, GraphicalComponent { }
Here it is difficult to write an implementation of draw() that can satisfy
the two different contracts independently. If you try to satisfy them sim-
ultaneously, you are unlikely to achieve the desired results: flipping a
card each time the screen gets repainted.
As with overriding in class extension, the overriding method is not per-
mitted to throw more checked exceptions than the method it overrides.
If two or more method declarations are inherited, without overriding,
and differ in the exceptions they throw, then the implementation of that
method must satisfy all the throws clauses of those declarations. Again
the main issue is whether such distinct methods can have a single im-
plementation that honors all contracts. We look further at the issues of
overriding and exception throwing in Chapter 12 .
If a declared method has the same name but different parameters from
an inherited method, then the declared method is an overloaded form of
the inherited method. The eventual class implementation will provide a
method body for each of the overloaded forms.
If a declared method differs only in return type from an inherited meth-
od, or if two inherited methods differ only in return type where one type
is not a subtype of the other, you will get a compile-time error.
 
Search WWH ::




Custom Search