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



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 have some questions : 1) Which type of GC used
View Tutorial          By: SP at 2013-06-04 15:48:59

2. can you provide the full class from start to begin
View Tutorial          By: mohit at 2011-12-01 09:56:22

3. Hi there, I was able to build this properly but he
View Tutorial          By: Damien at 2012-01-30 17:37:20

4. How to draw a thick circle in midlet?
View Tutorial          By: masi at 2011-12-01 11:47:00

5. heyy dis is not working with me .. plz suggest

View Tutorial          By: sahil at 2012-10-26 11:03:41

6. Nice article. Really helpful in understanding the
View Tutorial          By: Sundar at 2011-12-18 11:15:07

7. main is not needed for a simple program...

View Tutorial          By: manoj at 2012-05-29 17:46:08

8. May be someone would find this useful.


View Tutorial          By: Vsk at 2010-02-22 00:48:42

9. nice one.. i lik dis page... very informative for
View Tutorial          By: lokesh at 2013-01-10 09:06:22

10. Good programs example need for me
View Tutorial          By: G.Venugopal at 2009-11-11 08:46:38