What is another name for method overloading?
Static polymorphism.
Why is method overloading called static polymorphism?
Because method resolution happens at compile time based on parameter types.
What is method overloading in Java?
It is defining multiple methods with the same name but different parameter lists in the same class.
What must differ for methods to be overloaded?
Parameter number, types, or order must differ.
Can return type alone differentiate overloaded methods?
No. Return type alone is not sufficient for overloading.
When is overloaded method selection decided?
At compile time.
What is compile-time polymorphism?
Polymorphism where method binding is determined during compilation.
Is method overloading runtime polymorphism?
No. Overloading is compile-time polymorphism; overriding is runtime polymorphism.
Example of method overloading?
add(int a,int b) and add(double a,double b).
Can constructors be overloaded?
Yes. Constructor overloading is common.
Does inheritance matter for method overloading?
No. Overloading can occur within the same class without inheritance.
Why is method overloading useful?
It improves readability and allows same method name for related operations.
What is the key advantage of static polymorphism?
Faster execution because method binding occurs at compile time.
What happens if overloaded methods are ambiguous?
The compiler throws an ambiguity error.
How do you implement method overloading in Java?
By defining multiple methods with the same name in the same class but different parameter lists.
What must change to overload a method?
Parameter number, parameter types, or parameter order must differ.
Can methods be overloaded with different number of parameters?
Yes. Example: add(int a,int b) and add(int a,int b,int c).
Can methods be overloaded with different parameter types?
Yes. Example: add(int a,int b) and add(double a,double b).
Can parameter order be used for overloading?
Yes. Example: method(int,String) and method(String,int).
Is return type enough to overload methods?
No. Methods must differ in parameters, not just return type.
Does method name change in overloading?
No. Method name must remain the same.
Is method overloading compile-time or runtime?
Compile-time polymorphism.
Can static methods be overloaded?
Yes. Static methods can also be overloaded.
Can constructors be overloaded?
Yes. Constructor overloading is common for flexible object creation.