Java Reference
In-Depth Information
but not yet implemented, only if they are
abstract
classes.
If a normal class that is not
abstract
contains an
abstract
method, then a compile-time error
occurs.
It is a compile-time error for an enum type
E
to have an
abstract
method
m
as a member
unless
E
has one or more enum constants, and all of
E
's enum constants have class bodies
that provide concrete implementations of
m
.
It is a compile-time error for the class body of an enum constant to declare an
abstract
meth-
od.
A class
C
has
abstract
methods if any of the following is true:
• Any of
C
's superclasses has an
abstract
method and
C
neither declares nor inherits a
• A direct superinterface (§
8.1.5
) of
C
declares or inherits a method (which is there-
fore necessarily
abstract
) and
C
neither declares nor inherits a method that imple-
ments it.
It is a compile-time error if an attempt is made to create an instance of an
abstract
class using
A subclass of an
abstract
class that is not itself
abstract
may be instantiated, resulting in the
execution of a constructor for the
abstract
class and, therefore, the execution of the field ini-
tializers for instance variables of that class.
It is a compile-time error to declare an
abstract
class type such that it is not possible to create
a subclass that implements all of its
abstract
methods. This situation can occur if the class
but return types for which there is no type which is return-type-substitutable (§
8.4.5
) with
both.
Example 8.1.1.1-1. Abstract Class Declaration
abstract class Point {
int x = 1, y = 1;