Which class is super class of every class

What restrictions placed on method overloading

Answer : Method overloading can be done in same class or child class and below are restriction :

  • method names should be the same wherever you are overloading either parent or child class
  • Their parameter declaration should be different
  • return type may or may not be same of overloaded method
  • Two methods cannot have same name with same parameter in this case compiler will throw an exception
  • Compiler uses the method parameter to detect which overloaded method to refer at run time

Leave a Reply

Your email address will not be published. Required fields are marked *