1. Explain the concept of function overloading.
  2. Create multiple functions with same name in a JAVA class.
  3. Identify which function will be called by given function definition.

Function Overloading in JAVA

Vineet Agrawal

Published on January 7, 2017

You can create more than one functions with same name in a java class if their signatures are different.
Look at the 3 different variants of add() functions in the source code given below.

class fun_Overload
	int add(int a, int b)
		return a+b;
	int add(int a, int b, int c)
		return a+b+c;
	String add(String s1, String s2)
		return s1+s2;
	public static void main(String args[])
		fun_Overload fov=new fun_Overload();
		System.out.println(fov.add("Learn By", " Watch"));

Similarly you can make multiple functions in a java class.

This content is part of the following course: 
Frequently Asked Questions
Required Components