Higgledy Smith wrote:I remember things better if I understand the underlying reason for the behavior. That said, can anyone explain why static methods cannot be overridden?
Static methods can be hidden (but not overridden.) Why can't they be overridden? Because overriding uses polymorphism (which calls the correct method based on the actual type of the instance referred to by the reference.) But with static methods you have no underlying instance, since they are linked to the class as a whole. That's why you can't override a static method (but if you declare a static method with the same signature in a subclass, that static method will hide the superclass' static method in subclass code.)
All code in my posts, unless a source is explicitly mentioned, is my own.
It is worth noting that static methods cannot be abstract.
Joined: Dec 16, 2008
victor kamat wrote:It is worth noting that static methods cannot be abstract.
You are correct. Abstract methods are meant to be overridden, which static methods can not. Surprisingly, however, static methods can be marked final. A static method which is marked final can not be redefined in a subclass.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com