OOP Abstraction
Abstract Methods
An abstract method is declared without an implementation. That is curly bracket block is missing. In addition you must use keyword "abstract" at the beginning of declaration. Let's see:
Example:
Next code fragment implements an abstract method that have only name, no parameters and no return value. Also, declaration is ending with ";". There is no implementation block {...} therefore it requires to be declared abstract.
//declare abstract method with no result
abstract void draw();
Note:By declaring one abstract method in a class, the class must be also abstract. It can not be used but to be extended by a descendent class.
Abstract Classes
An abstract class is declared using keyword "abstract". This kind of class do have a block for implementation but inside the block we do not have all the methods implemented. Some can be abstract methods to be implemented in a descendent class.
Example:
Next code fragment implements an abstract class that have inside an abstract method:
//declare abstract method with no result
public abstract class GraphicObject {
// declare fields
...
// declare abstract methods
abstract void draw();
...
// declare nonabstract methods
...
}