Header Ads

  • Breaking Now

    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. :-)

    Post Top Ad

    Post Bottom Ad