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. How to print lee alone for the eg above........I n
View Tutorial          By: sa at 2013-04-01 07:43:03

2. thanks. worked.
View Tutorial          By: che at 2010-03-10 11:29:10

3. wonderful
simplified description
ke

View Tutorial          By: ephrem at 2010-01-14 06:12:05

4. very informative
View Tutorial          By: santhosh reddy WILLY at 2012-07-06 21:33:39

5. i need the code
View Tutorial          By: C.Ajith Franklin at 2010-05-05 06:04:40

6. can i also get the variable description for this p
View Tutorial          By: Maya Rao at 2013-10-04 06:06:00

7. Very simple and easy to understand... Thank u...
View Tutorial          By: Anu Priya at 2013-07-22 09:00:19

8. Works thnx :D :D :D :D
View Tutorial          By: nik at 2014-11-09 20:44:29

9. Thanks
Your solution helped me a lot :)

View Tutorial          By: sendhil at 2010-05-28 01:12:41

10. really very good example .now i have cleared what
View Tutorial          By: pushpendra bansal gurjar at 2012-02-15 12:19:58