Powered by Blogger.

Java Overloading Methods and Program Solution

Definition of Overloading Methods:-

We can declare several methods of same name in a class, which is known as methods overloading. For overloading methods argument lists must be different and return type can be different. In the following code, there are four methods of same name with different argument, which is an example of overloading methods.

Overloading Methods Program:-

 public class ABC{
    int a, b, c;

    public void setValue(){
       a=2;
       b=4;
       c=6;
    }

    public void setValue(int a){
       this.a=a;
       b=4;
       c=6;
    }

    public void setValue(int a, int b){
       this.a=a;
       this.b=b;
       c=6;
    }

    public int setValue(int a, int b, int c){
       this.a=a;
       this.b=b;
       this.c=c;
       int z = a+b+c;
       return z;
    }
  }

1 comment:

  1. Pretty good post. I just came across your site and wanted to say that I’ve really enjoyed reading your posts. In any case I’ll be subscribing to your feed and I hope you will keep a good work!Cheer!

    sap online training
    software online training
    sap sd online training
    hadoop online training
    sap-crm-online-training

    ReplyDelete