← Back to libraryQuestion 10 of 273
JavaBeginner

Method Overloading vs Overriding

📖 Detailed Explanation:

Method Overloading is Compile-Time polymorphism: same method name, different parameters in the SAME class. The compiler determines which method to call based on parameter types/count. Method Overriding is Run-Time polymorphism: same method name, same parameters, but in a child class providing a specific implementation. The actual method called is determined at runtime based on the object type.

🌍 Real-World Example:

Overloading: A printer that can print(String), print(int), print(byte[]). Overriding: A Vehicle class with move(), and Car/Airplane subclasses each override move() differently.

🎯 Scenario-Based Interview Question:

Can you override a static method? Why or why not? Explain with example.