The Abstract Modifier
Abstract Methods
An Abstract Method is one in which has a heading but no method body– this is to be defined in a derived classes.
- In order to postpone the definition of a method, Java allows an abstract method to be declared.
- Is like a placeholder for a method that will be fully defined in a descendent class.
- Has a complete method heading in addition to the
abstract
modifier. - cannot be private.
Abstract Class
An Abstract Class is one which includes an abstract method.
- Must have the modifier
abstract
included in its class heading. -Can have any number of abstract and/or fully defined methods. - If a derived class of an abstract class adds to or does not define all of the abstract methods, then it is abstract also, and must include the
abstract
modifier. - Conversely, a class which includes no abstract class is known as a concrete class.
- Cannot be instantiated.
- Constructor can be called by
super
and can callsuper
from another abstract class itself though.
- Constructor can be called by
- Can be used as a type (for instance as a parameter).