Question d’entretien chez DB Best Technologies

Can a static method be overridden or overloaded?

Réponse à la question d'entretien

Utilisateur anonyme

2 juil. 2019

Overloaded - yes. Everything works exactly the same way as with conventional methods - 2 static methods can have the same name if the number of their parameters or types is different. Redefined - no. The selection of the called static method occurs during early binding (at the compilation stage, not at the execution stage) and the parent method will always be executed, although the syntactically redefinition of the static method is a completely correct language construct. In general, reference to static fields and methods is recommended to be addressed through the name of the class, rather than an object.