Pregunta de entrevista de Merck

What is method overloading and method overriding in Java? Differentiate between them.

Respuesta de la entrevista

Anónimo

18 mar 2024

method overloading involves defining multiple methods with the same name but different parameter lists within the same class, whereas method overriding involves providing a new implementation for an existing method in a subclass. Overloading is resolved at compile-time based on the method signature, while overriding is resolved at runtime based on the object's actual type.