Originally posted by sam pitt:
I wrote a small code snippet, which declared a abstract static method. The code gave me a compile error. Can any one tell me why can't I have a static method declared as abstract ?
-Sam
Hi Sam,
First, 'static' method is a class method (i.e. cannot be overriden)
Second, a class with an abstract method cannot be initialized. Such class is used as a base for the subsequent subclass(es).
Third, any subsequent subclass of an abstract class, if it must be enabled for object creation or initialization, must provide a body for all abstract methods of its superclass as well as all the parent classes in the ancestory tree. That means such subclass must override the superclass's abstract method.
Overriding superclass's method is not possible if the superclass's method is declared with 'static' modifer as stated earlier.
Hope that helps,
Lam