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. Good explanation with simple language and style. N
View Tutorial          By: Ismail. MC at 2009-03-31 04:46:04

2. Very usefull info.. Thank alot
View Tutorial          By: Srikanth at 2012-09-04 15:44:30

3. one closing bracket ')' is required at while loop
View Tutorial          By: varsha Tambe at 2013-01-07 09:34:37

4. Hey guys, can u help me out over here..
thi

View Tutorial          By: Ridge Fernandes at 2012-01-19 04:09:45

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

6. Thanks, it solved my problem with "sun.securi
View Tutorial          By: haasdg at 2013-10-29 14:12:51

7. hi its working nice,can u plz help me how to fetch
View Tutorial          By: Manju gowda at 2014-02-21 07:23:44

8. In Step 2, I was getting this error: 'The term 'Co
View Tutorial          By: Geneie at 2012-11-22 02:28:13

9. the DomParserExample.java shows MAlformedURLExcept
View Tutorial          By: dipesh at 2011-12-09 09:53:46

10. Hagti hain.. the complete program has been copy pa
View Tutorial          By: Macho Man at 2012-06-21 07:58:03