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've been satisfied with your tutorial site. Since
View Tutorial          By: Mark Harold F. Manguino at 2008-08-06 05:00:54

2. sooooooooooooooooo gr8 jop!!
View Tutorial          By: monti at 2011-06-14 08:40:55

3. hi....
can u please show me the code for fi

View Tutorial          By: pooja at 2012-07-08 16:08:08

4. The code is running successfully.........but , I m
View Tutorial          By: Harshita at 2013-03-26 19:25:58

5. how to solve this problem

javax.com

View Tutorial          By: bhamre sandeep at 2010-02-28 04:18:36

6. The code to show recursion is ok, but the declara
View Tutorial          By: Gaurav at 2010-08-08 01:08:27

7. its good
View Tutorial          By: Srinu at 2011-05-26 23:57:18

8. THANX :)
View Tutorial          By: Saurabh at 2012-01-02 16:13:06

9. please i need the link to download the file requir
View Tutorial          By: kamahsteve at 2012-11-17 10:20:22

10. hai, i tried the abvoe code, m getting the follwin
View Tutorial          By: anith at 2011-03-13 06:02:31