Wednesday, April 18, 2007

Why an abstract method cannot be static?

An abstract method is usually defined in an abstract class or an interface,for which implementation is provided in a subclass or a class implementing the interface.As static methods just have single copy per class and are interpreted at code compile time,not at runtime, so it is impossible to have polymorphic behaviour out of them.In other words, they cannot be overridden.

An abstract class is one which cannot be instantiated but a static method defined in abstract class can be invoked without creating an instance.So there is no mechanism to ensure call of an abstract static method.

Moreover this is a design decision by language designers. :-)


Abhijeet Rathod on July 2, 2008 at 6:31 AM said...

More Explaination:
* static methods are final by default.
* final methods can't be overriden.
* abstract methods needs to be overidden in Child class whichever extending Abstract class.

Anonymous said...

An abstract class may have static fields and static methods. You can use these static members with a class reference—for example, AbstractClass.staticMethod()—as you would with any other class.
taken from

Anonymous said...

Static methods are not final by default !

Java Online Training on August 23, 2017 at 5:35 AM said...

Interesting post. Thanks for the information


Interview Questions On Java,Java EE Copyright © 2017. Reads: best tracker