Home  >  Forum  >  Core Java
Post New Query

What is method overloading in java? Tell me any example



Asked on September 16, 2014
give the example of methodoverloading in java


Replied on September 16, 2014
Method Overloading: When a class have multiple method by same name with different different argument is know as method overloading.

public class MethodOverload {
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) {
MethodOverload ob= new MethodOverload();
ob.sum(12, 8);
ob.sum(10, 10, 10);
}

}


Write Answer







©2019 concretepage.com | Privacy Policy | Contact Us