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



Ask a Question

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. iam getting intrest to watch this site
View Tutorial          By: monika at 2013-02-15 15:48:57

2. Your answer was right on the money! After searchi
View Tutorial          By: ooh la la at 2013-07-19 20:33:41

3. I HAVE ONE DOUBT.

public class Anim

View Tutorial          By: georgy at 2009-10-22 02:46:10

4. sir i m getting chat server started bt how a clien
View Tutorial          By: ashu at 2010-11-02 08:13:00

5. Yes, its possible to send SMS through web applicat
View Tutorial          By: Vidya at 2010-07-08 07:19:58

6. It is an excellent article. Please keep up the goo
View Tutorial          By: sanjay at 2011-03-09 03:17:45

7. your tutorial is very helpful...
i was hopi

View Tutorial          By: Zero17 at 2009-08-15 09:17:16

8. Great ! done a gud job
View Tutorial          By: Manju at 2012-11-02 06:43:58

9. The static variables are not in object scope inste
View Tutorial          By: Karthick at 2011-06-29 06:55:17

10. heyy dis is not working with me .. plz suggest

View Tutorial          By: sahil at 2012-10-26 11:03:41