How does Java resolve a call to an overloaded method?

Method overloading in Java is resolved during compilation. The compiler examines the method name, number of arguments, parameter types, and their order to determine which overloaded method should be invoked.

Key Points

Example

If a class contains display(int) and display(double), calling display(10) invokes the int version because it is the most specific match. Calling display(10.5) invokes the double version.

class Demo {

    void show(int x) {
        System.out.println("int method");
    }

    void show(double x) {
        System.out.println("double method");
    }

    public static void main(String[] args) {
        Demo d = new Demo();
        d.show(10);    // int method
        d.show(10.5);  // double method
    }
}

Interview Tip

A concise interview answer is: Java resolves overloaded methods at compile time by matching the method call with the most specific method signature based on the number, type, and order of arguments. If no suitable match exists or multiple methods are equally applicable, the compiler reports an error.

Last updated: 1 November 2026

Previous question: Can method overloading be determined at runtime?

Next question: What is the diamond operator, and how does it work?

More Core Java - Level III interview questions

All Core Java - Level III questions