Java Reference
In-Depth Information
It is a compile-time error if a method declaration that contains the keyword native also con-
tains strictfp .
If two or more (distinct) method modifiers appear in a method declaration, it is cus-
tomary, though not required, that they appear in the order consistent with that shown
above in the production for MethodModifier .
8.4.3.1. abstract Methods
An abstract method declaration introduces the method as a member, providing its signature
8.4.2 ) , return type, and throws clause (if any), but does not provide an implementation.
The declaration of an abstract method m must appear directly within an abstract class (call it
A ) unless it occurs within an enum (§ 8.9 ) ; otherwise a compile-time error occurs.
Every subclass of A that is not abstract 8.1.1.1 ) must provide an implementation for m , or
a compile-time error occurs.
It would be impossible for a subclass to implement a private abstract method, because
private methods are not inherited by subclasses; therefore such a method could never
be used.
An abstract class can override an abstract method by providing another abstract method declar-
ation.
This can provide a place to put a documentation comment, to refine the return type, or
to declare that the set of checked exceptions (§ 11.2 ) that can be thrown by that meth-
od, when it is implemented by its subclasses, is to be more limited.
An instance method that is not abstract can be overridden by an abstract method.
Example 8.4.3.1-1. Abstract/Abstract Method Overriding
Click here to view code image
class BufferEmpty extends Exception {
BufferEmpty() { super(); }
BufferEmpty(String s) { super(s); }
}
class BufferError extends Exception {
BufferError() { super(); }
BufferError(String s) { super(s); }
}
interface Buffer {
char get() throws BufferEmpty, BufferError;
Search WWH ::




Custom Search