Can static method be overridden?
Static methods are bonded during compile time (static binding).
And hence, it resolves to reference variable and not Object. And hence, you cannot override static method.
For e.g. -
Parent p = new Child();
p.callStaticMethod();
This method will invoke Parent class method and not Child class.
And hence, it resolves to reference variable and not Object. And hence, you cannot override static method.
For e.g. -
Parent p = new Child();
p.callStaticMethod();
This method will invoke Parent class method and not Child class.
Comments
Post a Comment