is method overloading is possible in this case -
i assume function overloading since has diff type of parameter .my question is
two functions, has diff type of parameter, diff return type considered function overloading?
public class header { public int addtwonumbers(int a, int b){ return a+b; } public double addtwonumbers(double a, double b){ return a+b; }
independently of programming language, method overload occurs when 2 or more methods have same identifier while parameters different either in number, order , type.
for example:
// overloading public void x(int a, double b) { } public void x(double a, int b) { }
in case, addtwonumbers
overloaded because 2 methods share same identifier while parameters have different types.
Comments
Post a Comment