Axaptapedia is now maintained by AgileCadence For more information please click here.

Abstract classes

From Axaptapedia
Jump to: navigation, search

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.

<xpp> abstract class AJ_Abstract {

 int x;//X is integer

} </xpp>

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.

<xpp> abstractObject = new AJ_Abstract(); </xpp>

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