Example 1: static polymorphism

public class StaticPolymorphism {
	void sum(int a, int b) {
		System.out.println(a + b);
	}

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

	public static void main(String[] args) {
		StaticPolymorphism obj = new StaticPolymorphism();

		obj.sum(1, 2, 3);
		obj.sum(1, 2);
	}
}
Output
6
3

Static Polymorphism with separated class

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

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

public class StaticPolymorphism {
	public static void main(String[] args) {
		Calculate cal = new Calculate();

		cal.sum(1, 2, 3);
		cal.sum(1, 2);
	}
}
Output
6
3