method overloading is an example of

Example 1: what is method overloading and method overriding in Java?

Method overloading is providing two separate methods in a class with the same name but different arguments, while the method return type may or may not be different, which allows us to reuse the same method name.

Method overriding means defining a method in a child class that is already defined in the parent class with the same method signature, same name, arguments, and return type

Example 2: method overloading in java

// Overloading by Changin the number of Arguments
class MethodOverloading {
    private static void display(int a){
        System.out.println("Arguments: " + a);
    }

    private static void display(int a, int b){
        System.out.println("Arguments: " + a + " and " + b);
    }

    public static void main(String[] args) {
        display(1);
        display(1, 4);
    }
}

Example 3: method overloading in framework

Method overloading is providing 
two separate methods in a class 
with the same name but different arguments,
while the method return type 
may or may not be different, which
allows us to reuse the same method name.
In my framework==
I use implicit wait in Selenium. Implicit wait
is an example of overloading. In Implicit wait
we use different time stamps such as SECONDS, MINUTES, HOURS etc.,
A class having multiple methods with
same name but different parameters 
is called Method Overloading

Example 4: method overloading

Method overloading is providing two separate methods in a class 
with the same name but different arguments, while the method return type 
may or may not be different, which allows us to reuse the same method name.

Tags:

Java Example