What issues might arise when both method overloading and overriding are used in the same class hierarchy?

Combining method overloading and overriding in the same class hierarchy can create ambiguity about which method actually gets invoked, because overload resolution happens at compile time based on the declared, or static, type, while overriding resolution happens at runtime based on the actual, or dynamic, type.

Key Points: • Overloading is resolved statically by the compiler based on the reference variable's declared type and the argument types at the call site. • Overriding is resolved dynamically at runtime based on the actual object type, via dynamic dispatch. • When a subclass both overrides a method and adds overloaded variants, calling through a superclass reference can invoke a different overload than expected if the compile-time and runtime types diverge. • This mix makes code harder to reason about and debug, since the same-looking call can resolve differently depending on the static type of the variable used to make it. • Best practice is to avoid overloading a method that's also being overridden with similar-but-not-identical signatures, since it's a common source of subtle bugs and reduces readability.

Example: If a superclass has process(Object obj) and a subclass overrides it while also adding an overload process(String str), calling process() through a superclass-typed reference holding a String will still invoke the Object overload, resolved at compile time, surprising anyone expecting the more specific overload to run.

Interview Tip: A concise interview answer is:

"Overloading is resolved at compile time using the declared type, while overriding is resolved at runtime using the actual object type. Mixing the two in a hierarchy can mean a call resolves to a different overload than intended when the static and dynamic types differ, which is why I avoid overloading methods that are also being overridden with similar signatures."