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. Thanks.... Nice Example
View Tutorial          By: Nagarjuna at 2012-05-29 12:00:50

2. Why not a simple array list of threads?
wha

View Tutorial          By: Ranadheer Machineni at 2011-08-18 12:30:35

3. Thanks summarized and useful
View Tutorial          By: Pegasus_Silvershade at 2010-09-10 18:02:49

4. I want to know about all java application.
View Tutorial          By: Ahasan at 2009-04-10 09:42:48

5. My code:

$hex=array('C4028000','457

View Tutorial          By: Mark at 2015-02-02 14:42:56

6. In your example http://twitter.com/statuses/updat
View Tutorial          By: thomas wilkinson at 2012-11-02 01:03:45

7. THANX FOR THE INFO....
View Tutorial          By: Abhinaykumar at 2010-07-06 11:34:53

8. hi!
please tell how i got the java comm api

View Tutorial          By: suresh at 2010-08-22 03:29:06

9. very useful example. Thanks for this help.
View Tutorial          By: Saurabh at 2010-04-23 04:50:13

10. hi,
plz help me i cannot find the way out o

View Tutorial          By: Yash at 2008-05-07 16:59:20