Comment on Tutorial - Method Overloading sample in Java By Ganesh Iyer



Comment Added by : Gaurav

Comment Added at : 2013-07-28 15:53:20

Comment on Tutorial : Method Overloading sample in Java By Ganesh Iyer
You can not overload the private method in Test class.
there is no problem with protected method.
check out this and try to run

public class A
{
int aa,bb,addd,pp,qq,rr,add2,ss,tt,uu,vv,add3;
void overload(int a,int b)//===========1
{
aa=a;
bb=b;
addd=aa+bb;
System.out.println("Addition is="+addd);
}
private void overload(int p,int q,int r)//============2
{
pp=p;
qq=q;
rr=r;
add2=pp+qq+rr;
System.out.println("Addition is="+add2);
}
protected void overload(int s,int t,int u,int v)//========3
{
ss=s;
tt=t;
uu=u;
vv=v;

add3=ss+tt+uu+vv;
System.out.println("Addition is="+add3);
}
}



class test
{
public static void main(String a[])
{
A a1=new A();
a1.overload(23,55);
A a2=new A();
a2.overload(20,40,60);
A a3=new A();
a3.overload(20,40,6,100);



}
}

if not getting debug then try to make private method as public and check out,,,,,,,,,,,,,,
Thanks


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. short and simple program
hel

View Tutorial          By: sourabh agrawal at 2012-10-16 04:55:27

2. Hi i have studied these programs.
but unabl

View Tutorial          By: Karuna at 2008-03-30 08:46:00

3. Good Explanation for the collections. The output f
View Tutorial          By: kalaivanan at 2012-04-11 06:51:49

4. not good not bad...............
View Tutorial          By: mahesh at 2010-10-05 00:45:54

5. Everything is running.... But it doesn't send....<
View Tutorial          By: uu at 2009-04-09 18:10:13

6. its a big help!..thankz
View Tutorial          By: mezer at 2013-07-17 05:34:07

7. Nice Explanation.....
View Tutorial          By: Vinoth at 2012-06-20 09:37:21

8. i want to how to run a package and compile also
View Tutorial          By: sandhya at 2015-06-25 09:04:03

9. I wanna to name ,subject and marks of every subjec
View Tutorial          By: raveesh yadav at 2012-10-13 19:56:47

10. Hi Jigar,
The above applicatio

View Tutorial          By: Kiran at 2011-12-26 04:00:24