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. can u please send me the code for sending sms from
View Tutorial          By: Vicky at 2008-03-20 02:34:27

2. hi and thanks for this good example , i want ask i
View Tutorial          By: Maryam at 2011-12-17 11:19:07

3. can u explain about printStackTrace()method.what i
View Tutorial          By: himabindu at 2009-06-10 20:03:14

4. sir, i need java code to display position and velo
View Tutorial          By: Sandhya Yadav at 2015-08-20 07:16:04

5. Hi,
I need to put in a picturebox on VB .NE

View Tutorial          By: Marcio Rodrigues at 2009-11-27 05:07:09

6. super excellent
View Tutorial          By: mani at 2013-05-27 05:32:06

7. Can you please send me complete sample code of cha
View Tutorial          By: Brajesh at 2011-04-21 05:48:17

8. HI.....

javax.comm.NoSuchPortExcept

View Tutorial          By: RAHUL at 2010-12-28 22:59:41

9. Hi This is very fine to understanding struts flo
View Tutorial          By: Abinash at 2011-06-28 08:27:18

10. can any beginners can try creating web pages

View Tutorial          By: jo at 2015-07-28 19:35:11