What do you mean by Method Overloading in Java?

2024

What do you mean by Method Overloading in Java?

  1. A.

    Having two methods with the same name in different packages.

  2. B.

    Having two methods with the same name and same parameters.

  3. C.

    Having two methods with the same name but different parameters.

  4. D.

    Having two methods with the same name in different classes.

  5. E.

    Question not attempted

Attempted by 115 students.

Show answer & explanation

Correct answer: C

Method Overloading in Java means defining multiple methods in the same class with the same method name but different parameter lists (different number, type, or order of parameters).
It is an example of compile-time polymorphism.

Example

class Demo {
    void add(int a, int b) {
        System.out.println(a + b);
    }

    void add(int a, int b, int c) {
        System.out.println(a + b + c);
    }
}

Here, both methods are named add() but have different parameters, so this is Method Overloading.

Explore the full course: Up Lt Grade Assistant Teacher 2025