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. You do not give an example on fillratio i want to
View Tutorial          By: reguieg at 2015-08-23 20:53:50

2. i want to SCJP exam ,tell how to apply for this ex
View Tutorial          By: jasmina at 2013-04-22 11:05:53

3. file reader is good but file writer is worst
View Tutorial          By: sachinmani at 2010-03-01 04:34:22

4. I want to be programer
View Tutorial          By: somphone at 2015-09-09 11:20:20

5. How could i read a file from my ftp server . sugge
View Tutorial          By: Dinshaw at 2015-02-06 07:22:03

6. Good hello world to start with struts2 provided yo
View Tutorial          By: Boby Thomas at 2009-04-01 22:25:03

7. I've been learning C++/C for the past year or so,
View Tutorial          By: William Semple at 2013-01-05 17:53:30

8. What exactly is d directry for d folder Media?? It
View Tutorial          By: Oraclematrix at 2012-01-15 21:40:54

9. Please provide web.xml for the example
View Tutorial          By: Amit at 2008-12-24 02:16:59

10. @Zero Code

@
Catch ex As Ex

View Tutorial          By: Chitz at 2011-12-24 19:50:45