Abstract Classes Can Define Constants
Abstract class can have normal functions and variables along with a pure virtual function.
Abstract classes can define constants. You can force sub class to define a method which can be a constant for that class. Protected abstract string objectdef. Interfaces can extend other interfaces one or more but not classes abstract or not. An abstract class can inherit a class and multiple interfaces.
An interface only has method declarations or abstract methods and constant data members while an abstract class may have abstract methods member. Constants differ from normal variables in that you dont use the symbol to declare or use them. Abstract classes serve as templates for their subclasses. Hence any data declaration is public static final.
Abstract class cannot be instantiated but pointers and refrences of abstract class type can be created. Class constants it is possible to define constant values on a per class basis remaining the same and unchangeable. An abstract class allows you to define both fields and constants. An interface can inherit multiple interfaces but cannot inherit a class.
For example the abstract class tree and subclass banyantree has all the characteristics of a tree as well as characteristics that are specific to the banyan tree. Understanding the differences between an abstract class and an interface is essential. Till java 7 version an interface in java is a pure abstract class which means all methods are abstract and variables are constants by default all methods inside interface are public abstract and variables are public static final interface is a mean to achieve full abstraction in java. The default visibility of class constants is public.
An abstract class defines the identity of a class. No fields can be defined. If you have sub class of your sub classes these might forget to override these methods. Either define a constant in the abstract class thus every child class has a constant even if it does not define its own or use an abstract function which forces every child class to define its own.
Characteristics of abstract class. Abstract classes are mainly used for upcasting so that its derived classes can use its interface. Techopedia explains abstract class. Protected abstract string objectname.