This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Because static methods cannot be overridden, that is, they do not exhibit polymorphic behaviour. An abstract method is meant to be provided an implementation by one overridding method in a subtype of the type where it was declared. The abstract method was born to be overriden. However a static method already has an implementation that is independent of any instance of its class, and of course, independent of instances of subtypes. The implementation of a static method is bound to the type where it was declared. This is the opposite to polymorphism. The static method was born to be called as it is, without the need to create any instance.
To understand this -- you really need to have a good understanding of some basic OO ideas -- like inheritance and overriding. When you extend a class, you inherit all of its accessible instance members (accessibility is of course defined by the access modifiers: private, public, protected or the default access level -- no modifier). Notice I said you inherit its instance members -- not the static ones that belong to the class, and not the object. On the other side you have the modifier abstract -- by definition, if you declare a method as abstract you're saying that this method has to be overridden by the subclass unless of course you declare the subclass as abstract too... and then you've gotta do the whole thing over again with it's subclass -- but that's beside the point. So -- what we've got so far: -- a static method will not be inherited when by your subclass. -- an abstract method MUST be overriden by the subclass. See how the two conflict? You can't have something defined as static abstract because then you're saying "This thing belongs to the class, not the object, so it won't be inherited when this class is extended; on the other hand -- this method MUST be overridden when this class is extended" -- a total contradiction -- so the compiler won't allow it.
Thank u all very much... I could get the reason why its impossible. thanks again... basanti
Joined: Jul 03, 2001
I would say that static members are inherited. Though static methods cannot be overridden, but hidden. From JLS 8.4.6
A class inherits from its direct superclass and direct superinterfaces all the non-private methods (whether abstract or not) of the superclass and superinterfaces that are accessible to code in the class and are neither overridden (�22.214.171.124) nor hidden (�126.96.36.199) by a declaration in the class.