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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Java program to get location meta data from an image
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
Archived Comments
1. Thank you a lot for sharing your knowledge! It was
View Tutorial By: Marcelo at 2013-01-17 03:07:37
2. javax.microedition.io.ConnectionNotFoundException:
View Tutorial By: yellaiah at 2014-12-27 05:18:52
3. I am still going through the tutorial, but it seem
View Tutorial By: shadowwraith at 2011-06-08 08:00:57
4. i want some explanation about struts form field va
View Tutorial By: ramizah at 2007-10-03 23:40:11
5. clear concept explanation..
View Tutorial By: ASHOK at 2013-01-16 07:31:35
6. what about the remaining explanation......do anyth
View Tutorial By: raki at 2011-11-07 10:47:25
7. nice code. code is running perfectly. but my probl
View Tutorial By: Avinash at 2013-01-28 07:30:19
8. Looks good. This is going to be a good resource.
View Tutorial By: Brainpower at 2013-03-02 02:45:11
9. this is really very useful because of this site i
View Tutorial By: meenakshi shukla at 2012-09-15 05:09:49
10. i have run the code successfully but it does not s
View Tutorial By: amrish at 2010-12-11 07:00:28