Automatic type promotion in Java occurs when a smaller data type is automatically converted to a larger data type during method overloading. It helps the compiler choose the most suitable method when an exact match is not available. This feature ensures flexibility and avoids compilation errors in overloaded method calls.
- Promotion happens from smaller to larger data types (e.g.,
int → long → float → double). - Used when no exact method match is found during method overloading.
- Does not allow conversion from larger to smaller data types and may cause ambiguity errors.

Note:- This is important to remember is Automatic Type Promotion is only possible from small size datatype to higher size datatype but not from higher size to smaller size. i.e., integer to character is not possible.
Example: In this example, we are testing the automatic type promotion from small size datatype to high size datatype.
class GFG {
// A method that accept double as parameter
public static void method(double d)
{
System.out.println(
"Automatic Type Promoted to Double-" + d);
}
public static void main(String[] args)
{
// method call with int as parameter
method(2);
}
}
Output
Automatic Type Promoted to Double-2.0
Explanation: Here we passed an Integer as a parameter to a method and there is a method in the same class that accepts double as parameter but not Integer. In this case, the Java compiler performs automatic type promotion from int to double and calls the method.
Example: Let's try to write a code to check whether the automatic type promotion happens from high size datatype to small size datatype.
class GFG {
// A method that accept integer as parameter
public static void method(int i)
{
System.out.println(
"Automatic Type Promoted possible from high to small?");
}
public static void main(String[] args)
{
// method call with double as parameter
method(2.02);
}
}
Output:
Explanation: From this example, it is proven that Automatic Type Promotion is only applicable from small size datatype to big size datatype. As the double size is large when compared to integer so large size to small size conversion fails.
Example: In this example, we are going to look at the overloaded methods and how the automatic type of promotion is happening there.
class GFG {
// A method that accept integer as parameter
public static void method(int i)
{
System.out.println(
"Automatic Type Promoted to Integer-" + i);
}
// A method that accept double as parameter
public static void method(double d)
{
System.out.println(
"Automatic Type Promoted to Double-" + d);
}
// A method that accept object as parameter
public static void method(Object o)
{
System.out.println("Object method called");
}
public static void main(String[] args)
{
// method call with char as parameter
method('a');
// method call with int as parameter
method(2);
// method call with float as parameter
method(2.0f);
// method call with a string as parameter
method("Geeks for Geeks");
}
}
Output
Automatic Type Promoted to Integer-97 Automatic Type Promoted to Integer-2 Automatic Type Promoted to Double-2.0 Object method called
Explanation: In the above code,
char 'a'is promoted toint(97) and calls theintmethod.intvalue directly matches, so no promotion happens.floatis promoted todoubleand calls thedoublemethod.Stringhas no exact match, so it calls theObjectmethod (no primitive promotion, uses inheritance).
Example: In this example, consider the overloaded methods with more than one argument and observe how automatic type conversion is happening here:
class GFG {
// overloaded methods
// Method that accepts integer and double
public static void method(int i, double d)
{
System.out.println("Integer-Double");
}
// Method that accepts double and integer
public static void method(double d, int i)
{
System.out.println("Double-Integer");
}
public static void main(String[] args)
{
// method call by passing integer and double
method(2, 2.0);
// method call by passing double and integer
method(2.0, 2);
// method call by passing both integers
// method(2, 2);
// Ambiguous error
}
}
Output
Integer-Double Double-Integer
Explanation: In the above code,
- Compiler first looks for an exact match method; if found, it calls it.
- If not, it tries automatic type promotion.
- When passing two integers, both overloaded methods are possible after promotion, causing ambiguity, so the compiler throws an error.
These are the few examples that can give clear insight on Automatic type conversion in overloaded methods.