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. i use your program to read my GPS ( in COM11 ) .
View Tutorial          By: Dinesh rajapaksha at 2009-11-17 07:25:19

2. Thanks a lot. In a very Simple way you explained.<
View Tutorial          By: Shoaeb uddin at 2012-01-13 18:53:45

3. Your Work is Good, But i want to ask if there is a
View Tutorial          By: Good Muyis at 2011-01-08 09:47:14

4. hi, would you please send me the detail to impleme
View Tutorial          By: nayeem at 2009-03-13 08:47:27

5. It is very helpful, I searched in many websites, b
View Tutorial          By: Anil Vaja at 2013-10-14 17:21:42

6. gudeveniing!! plz gave me some project title gor j
View Tutorial          By: ivie at 2012-12-12 11:00:43

7. This is a good tutorial. Now how can I send SMS mu
View Tutorial          By: Alkesh at 2013-05-11 14:51:53

8. practical example of funcation overloding
View Tutorial          By: yogesh at 2010-12-19 08:39:06

9. Assume scenario:
- i have set connection po

View Tutorial          By: Dan at 2012-02-22 09:48:46

10. thanks 4 d inf..
View Tutorial          By: Ankur Saxena at 2012-02-10 15:31:33