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. I have download that 5 files .But how to run this
View Tutorial          By: Unnati at 2011-07-07 06:07:26

2. Good piece of information explained wonderfully. !
View Tutorial          By: Juzar at 2009-07-23 00:24:40

3. i need to send some file usin a bluetooth devicem
View Tutorial          By: igle85 at 2012-01-25 06:27:50

4. Thanks for the help, however I am having some diff
View Tutorial          By: Andrew at 2008-09-30 14:51:14

5. A big thanks to Ramlak for the detailed and crisp
View Tutorial          By: Chidanand Gangur at 2009-08-27 06:02:16

6. for the guys who is facing problems
just c

View Tutorial          By: Elie at 2010-05-03 12:12:48

7. thanku very much. it is a good examples for abstr
View Tutorial          By: rajesh at 2010-12-17 10:57:42

8. Muchas Gracias, me ha servido de mucho el aporte.<
View Tutorial          By: Juan Carlos at 2009-03-25 18:11:37

9. Great one on java-xml binding..
View Tutorial          By: Ranadeep Roy at 2008-07-03 23:15:22

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