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. Sir,
i am implementing the above code in w

View Tutorial          By: Rahul Singh at 2009-09-01 04:23:25

2. Hello Mr. Developer of above proj....plz let me kn
View Tutorial          By: Prakash Vishwakarma at 2011-07-08 10:02:22

3. Well the code is good but what if students start e
View Tutorial          By: nitin kumar sharma at 2015-07-15 06:58:18

4. Sorry, I can't understand what is really apply and
View Tutorial          By: Ejita at 2012-02-01 05:38:09

5. When stateless bean not maintains any state and no
View Tutorial          By: Mallikarjun at 2015-09-18 15:42:46

6. thank's for the info.. i've learned a lot.. now, i
View Tutorial          By: farah talabo at 2012-01-08 23:55:14

7. not work
View Tutorial          By: kkbb at 2011-03-12 03:52:06

8. A more complete description of the common pitfalls
View Tutorial          By: Phil at 2012-11-25 02:06:49

9. nice its working good example.... very useful...
View Tutorial          By: Mamatha at 2012-02-02 09:23:40

10. what if i use multiple switch statement, is it wor
View Tutorial          By: earl at 2012-01-29 04:10:25