Tuesday, November 29, 2011

What restrictions are placed on method overloading?

Two methods may not have the same name and argument list but different return types.:In method overloading function name will be same but the argument count or type or order must vary. They can have different return type also.:The only restriction on method overloading is the signature of the method.The signature is the number, type, and order of the arguments passed to a method.Any number of methods which have the same name(unless overridden) cannot have the same signature,though they can have the same return types in the same scope.The compiler uses the signature to detect which overloaded method to refer when a overloaded method is called.If two methods have the same name and signature the compiler will throw an runtime error. :restrictions for method overloading:
Category:Java Interview Questions

No comments:

Post a Comment