Revature interview question

What is method overloading? Overriding?

Interview Answer

Anonymous

Jul 18, 2017

Method overloading is where you have multiple methods with the same name but they accept different parameters. For instance: myMethod(int i) [ //method body here ] myMethod(string s) [ //method body here ] Then the method that will be used will be determined at run time based on the type of data you send it (the one with the matching parameters/arguments). Method overriding is when you have a method that is predefined from a class definition, then when you create an object instance you override, or redefine the method body for that particular instance. You could think of it as a manual override, like when a group of machines are pre-programmed to operate a certain way, but you can override one to do what you want, which would probably be something similar to what is was originally programmed to do.