Java Programming/Keywords/abstract
From Wikibooks, open books for an open world
abstract is a Java keyword. ... It declares a class abstract, not all its methods are defined/implemented. Objects are not normally created from an abstract class. Rather, they are created from either a non-abstract subclass, or by having the functions declared alongside a new statement (which is not recommended).
It also declares a method abstract, that is, not implemented in the abstract class. A method cannot be declared abstract in a non abstract class.
Syntact:
publicabstractclassClassName orabstractpublicclassClassName
and for methods in an abstract class :
publicabstractvoid methodName(); // --- No body, no implementation --- orabstractpublicvoid methodName(); // --- No body, no implementation ---
For example:
public abstract ClassName { // --- This method does not have a body; it is abstract. --- public abstract void abstractMethod(); // --- This method does have a body; it is implemented in the abstract class and gives a default behavior. --- public void normalMethod() { ... } } |
This page may need to be