What is the difference between overloading and overriding?
Why Interviewers Ask This
This is a classic screening question for OOP Concepts roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
Method Overloading and Method Overriding are both ways to have multiple methods with the same name, but they serve different purposes: Overloading (compile-time polymorphism): defining multiple methods with the SAME name but DIFFERENT parameter lists within the SAME class. The compiler selects the right method based on argument types and count: class MathHelper { public int multiply(int a, int b) { return a * b; } public double multiply(double a, double b) { return a * b; } public int multiply(int a, int b, int c) { return a * b * c; } // INVALID -- only return type differs (not allowed!): // public long multiply(int a, int b) { return (long)a * b; } } MathHelper m = new MathHelper(); m.multiply(2, 3); // int version m.multiply(2.0, 3.0); // double version m.multiply(2, 3, 4); // 3-param version. Overriding (runtime polymorphism): redefining a method from a PARENT class in a CHILD class with the SAME name and SAME parameter list: class Logger { public void log(String message) { System.out.println("[INFO] " + message); } } class DebugLogger extends Logger { @Override // Annotation ensures proper override -- compiler error if wrong public void log(String message) { System.out.println("[DEBUG] " + Thread.currentThread().getName() + ": " + message); } } Logger logger = new DebugLogger(); logger.log("test"); // Calls DebugLogger.log() -- runtime dispatch. Key differences: Overloading = same class, different signature, compile-time; Overriding = parent-child, same signature, runtime. @Override annotation (Java) catches errors where you think you're overriding but aren't.
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong OOP Concepts candidates.