In: Computer Science
What does it mean when a method is overloaded? Give an example of overloading the method isNotInRange so that can be called like isNotInRange(100, 97, 122);
Method overloading
Ans: Method overloading means when a function has the same name but it does different work. In method overloading, function signatures are different. The method signature consists of four things as given below.
Out of these 4, the function name is the same and other three varies in some way.
Give an example of overloading the method isNotInRange
Ans:
1. void isNotInRange(int,int,int)
2. void isNotInRange(int,int)
3. void isNotInRange(int)
Here isNotInRange() is overloaded and we can call three methods with different parameters
isNotInRange(100,97,122) //it will call 1st method
isNotInRange(100,97) //it will call 2nd method
isNotInRange(97) //it will call 3rd method