Home  >  Forum  >  Core Java
Post New Query

What is method overloading in java? Tell me any example


joined on
September 16,2014
Asked on September 16,2014
give the example of methodoverloading in java
joined on
September 16,2014
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









Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us