Comment on Tutorial - Method Overloading sample in Java By Ganesh Iyer



Comment Added by : ITMIT

Comment Added at : 2011-06-05 19:16:46

Comment on Tutorial : Method Overloading sample in Java By Ganesh Iyer
public class Overload2 {

void add(int m, int n)
{
int sum = m + n;
System.out.println( "Sum of a+b is " +sum);
}

void add(int a, int b, int c) {

int sum = a + b + c;
System.out.println("Sum of a+b+c is " +sum);

}

void add(double a, double b) {

double sum = a + b;
System.out.println("Sum of a+b is "+sum);
}

void add(String s1, String s2)
{
String s = s1+s2;
System.out.println(s);
}
}
class overloadfunc{

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

obj.add(4,19);

obj.add(4,17,11);

obj.add(1.5,21.5);

obj.add("Life at"," the speed of rail ");
}

}




Output will be:
Sum of a+b is 23
Sum of a+b+c is 32
Sum of a+b is 23.0
Life at the speed of rail


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. too good post....very easy to understand
View Tutorial          By: Rahul at 2013-03-04 17:09:58

2. Thanks a lot......Plz help me to execute these fil
View Tutorial          By: Sanjana at 2013-01-26 10:15:12

3. Thank you!!!!!
View Tutorial          By: wsjonly at 2013-09-19 18:41:50

4. Well first-oof, I don't see the obvious app.
View Tutorial          By: Marvin Ambrose at 2010-10-07 01:30:30

5. Explanation was good and easily comprehendable.
View Tutorial          By: Moin Adil at 2009-06-17 04:18:56

6. Excellent !!!
Never thought about it...

View Tutorial          By: RahulC at 2012-07-03 11:36:57

7. A very good demonstration o Vector!!
View Tutorial          By: Pankaj Kumar Mishra at 2010-12-09 01:35:06

8. i like the example and it helped me understand the
View Tutorial          By: Danny at 2009-10-23 02:09:06

9. How to send to multiple mobiles at a time
View Tutorial          By: rakesh at 2010-04-30 10:33:51

10. It worked. Thank U!
View Tutorial          By: Abhijit Kurane at 2010-12-27 11:01:48