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



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. Re: Inner Classes
Aside from allowing acces

View Tutorial          By: lee smith at 2010-01-17 10:59:23

2. In my Midlet class there is a constructor which i
View Tutorial          By: nicolas at 2011-11-12 21:35:58

3. i can't understand the deadlock clearly
View Tutorial          By: kalpana at 2012-11-01 11:26:09

4. hi all !

This is the error im getti

View Tutorial          By: Ajit at 2010-02-17 23:09:47

5. Thank you very much sir.
One can simply exe

View Tutorial          By: rudhin at 2013-05-10 12:32:57

6. I dont know the reason why have a exception!

View Tutorial          By: Nguyen Tien Viet at 2008-04-05 06:01:50

7. #include<iostream>
#include<conio.

View Tutorial          By: XavioR at 2011-01-31 00:53:11

8. everything is easy to learn from your website.I un
View Tutorial          By: sumitra barua at 2012-05-30 03:13:10

9. one of the best example for trim()....
View Tutorial          By: sharad at 2013-01-29 13:43:58

10. thanks a looooooooooooooooot
this can give

View Tutorial          By: bhagabat at 2011-07-24 02:39:59