Java Reference
In-Depth Information
ation. If the expected return type is not acceptable in the code (for ex-
ample, the method returns a String but the method call is used as an
array subscript) or if the checked exceptions are not dealt with correctly
you will get a compile-time error.
For instance, suppose you had the following type hierarchy:
Also suppose you had several overloaded methods that took particular
combinations of Dessert parameters:
void moorge(Dessert d, Scone s) { /* first form */ }
void moorge(Cake c, Dessert d) { /* second form */ }
void moorge(ChocolateCake cc, Scone s) { /* third form */ }
void moorge(Dessert... desserts) { /* fourth form */ }
Now consider the following invocations of moorge :
moorge(dessertRef, sconeRef);
moorge(chocolateCakeRef, dessertRef);
moorge(chocolateCakeRef, butteredSconeRef);
moorge(cakeRef, sconeRef); // INVALID
moorge(sconeRef, cakeRef);
 
Search WWH ::




Custom Search