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. There something at Example #2! because when i try
View Tutorial          By: Paul at 2011-08-01 14:38:14

2. Thank you very much you resolved my issue.
View Tutorial          By: ketan at 2012-02-01 11:16:47

3. So I appreciate this website, however... would it
View Tutorial          By: Christina at 2013-02-06 16:46:12

4. I dont know the reason why have a exception!

View Tutorial          By: Nguyen Tien Viet at 2008-04-05 06:01:50

5. i have to retrieve data from database which is on
View Tutorial          By: abhishek at 2012-04-05 05:04:01

6. Right, so were is the tutorial files.zip?
O

View Tutorial          By: jeremy at 2011-10-24 15:58:40

7. Enabling IPV6 at Application Level


View Tutorial          By: i want code , can you send me at 2014-12-28 11:43:35

8. It is very useful ....Thank U sooo much dear...
View Tutorial          By: Augustine Francis at 2014-06-24 16:55:21

9. Thankyou it is Working Fine .....
View Tutorial          By: PDCOE at 2009-02-11 23:02:29

10. if suppose i am having connection pool max size 30
View Tutorial          By: Shrikant at 2012-07-20 12:09:33