Final answer:
Method overloading is when a class has multiple methods with the same name but different parameters, altering the method's signature. It enables methods to handle various data types and argument counts, which enhances code flexibility and readability.
Step-by-step explanation:
Method overloading refers to the practice within object-oriented programming where a class has two or more methods with the same name but different parameters. In essence, method overloading occurs when there is a presence of multiple methods in the same class with the same name but each has a different signature. A method's signature includes the number, type, and order of parameters; however, it does not include the method's return type. Therefore, the correct answer to the question is c) When two or more methods have the same name but different parameters.
For example, consider a class with a method named "add" that adds two integers. You can overload this method by creating another "add" method that takes in three integers, thus changing its signature. Both methods have the same name but differ in the number of parameters they accept:
- int add(int a, int b)
- int add(int a, int b, int c)
Overloading allows methods to handle different types of data and numbers of arguments, providing flexibility and improving code readability.