Abstract classes

An Abstract class is used when the developer wishes to ensure that a particular class cannot be instantiated. This applies when sub-classes will be created which contain the real functionality, and it is meaningless to create an instance of the parent class.

A class is declared as abstract in the Class Declaration.

abstract class AJ_Abstract { int x;//X is integer }

As can be seen in the example, it is possible to put variable declarations inside an abstract class. It is also possible to add both abstract and concrete (non-abstract) methods on that class.

It is not possible to instantiate an object of this class.

abstractObject = new AJ_Abstract;

Using the example above, this code will give a compile error.