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 set my eclipse as describe above.
I also

View Tutorial          By: Anonymous at 2012-03-25 02:12:52

2. Many Thanks.
View Tutorial          By: Kallol Samaddar at 2013-07-11 18:26:06

3. Thanks, It's exactly. A my friends has the same is
View Tutorial          By: Slim at 2012-09-29 02:52:12

4. #include<stdio.h>
void main(){

View Tutorial          By: niru at 2012-07-21 07:26:27

5. import java.util.*;

public class de

View Tutorial          By: Virudada at 2012-05-05 06:27:22

6. Please give me a example of regionMatches().
View Tutorial          By: A. K. M. Saleh Sultan at 2009-10-05 14:52:25

7. Hi,

I am new to html, and javascrip

View Tutorial          By: Tom Theriault at 2010-12-14 14:54:09

8. comm.jar file for windows not available in sun. ca
View Tutorial          By: borus at 2015-03-25 07:19:57

9. /* File name : Employee.java */
public abst

View Tutorial          By: Anonymous at 2012-11-16 12:23:17

10. Gooooooooooodd !!!
View Tutorial          By: Digvijoyee at 2010-08-30 22:11:31