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. but need in the case of radio buttons
View Tutorial          By: vishnu at 2011-07-21 11:39:26

2. Hi All........
People those who are ge

View Tutorial          By: Abhijit at 2013-05-28 11:24:24

3. hi,good afternoon i have one problem with spinner
View Tutorial          By: veera reddy at 2012-01-13 06:55:24

4. how to read any xml file or i want to a universal
View Tutorial          By: shankar lal at 2014-09-29 12:40:20

5. HI can you send send sms throgh java program above
View Tutorial          By: sasikumar at 2007-02-27 01:39:11

6. I am an MCA student i wanna know whether one can s
View Tutorial          By: RAJU.K at 2009-07-24 02:28:21

7. string strInsert = "Insert into [Sheet1$](F1,
View Tutorial          By: Sagar at 2011-05-12 06:47:13

8. very helpful to me.thanks.very very useful to me.
View Tutorial          By: viji at 2007-12-21 03:17:14

9. Splendid! Haven\'t used asserts before, very helpf
View Tutorial          By: Anonymous at 2009-03-11 04:18:42

10. import java.io.File;
import java.util.Scann

View Tutorial          By: sa at 2012-08-02 07:09:30