employer cover photo
employer logo
employer logo

DB Best Technologies

Is this your company?

DB Best Technologies interview question

Can a static method be overridden or overloaded?

Interview Answer

Anonymous

2 Jul 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.