Wednesday 27 March 2013

Can you override static method in Java?


No. We can not override static method in java.
Overriding depends on having an instance of a class.
The point of polymorphism is that you can subclass a class and the objects implementing those subclasses will have different behaviors for the same methods defined in the superclass (and overridden in the subclasses).
A static method is not associated with any instance of a class so the concept is not applicable.

No comments:

Post a Comment