8.4.3
Method Modifiers
CLASSES
subclass
C
 of the
abstract
 class
A
, if
C
 is not
abstract
, then there must be some
class
B
 such that all of the following are true:
B
 is a superclass of
C
or is
C
 itself.
B
 is a subclass of
A
.
B
 provides a declaration of the method
m
 that is not
abstract
, and this decla 
ration is inherited by
C
, thereby providing an implementation of method
m
that is visible to
C
.
If there is no such class
B
, then a compile time error occurs.
It is a compile time error for a
private
 method to be declared
abstract
. It
would be impossible for a subclass to implement a
private abstract
 method,
because
private
 methods are not visible to subclasses; therefore such a method
could never be used.
It is a compile time error for a
static
 method to be declared
abstract
.
It is a compile time error for a
final
 method to be declared
abstract
.
An
abstract
 class can override an
abstract
 method by providing another
abstract
 method declaration. This can provide a place to put a documentation
comment ( 18), or to declare that the set of checked exceptions ( 11.2) that can
be thrown by that method, when it is implemented by its subclasses, is to be more
limited. For example, consider this code:
class BufferEmpty extends Exception {
BufferEmpty() { super(); }
BufferEmpty(String s) { super(s); }
}
class BufferError extends Exception {
BufferError() { super(); }
BufferError(String s) { super(s); }
}
public interface Buffer {
char get() throws BufferEmpty, BufferError;
}
public abstract class InfiniteBuffer implements Buffer {
abstract char get() throws BufferError;
}
The overriding declaration of method
get
 in class
InfiniteBuffer
 states that
method
get
 in any subclass of
InfiniteBuffer
 never throws a
BufferEmpty
exception, putatively because it generates the data in the buffer, and thus can never
run out of data.
158






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved