difference b/w over loading and overridding

Discussion in 'Programming' started by leejohn, Sep 29, 2011.

  1. #1
    please specify difference between over ridding and over loading in java
     
    leejohn, Sep 29, 2011 IP
  2. softwebsolutions

    softwebsolutions Active Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #2
    In overriding method, subclass has the same name and signature as a method in its super class. It means subclass is overriding the method in the super class. For example,
    Class A
    { Virtual void Hello (int a)
    {}
    }
    Class B: A
    { public override void Hello(int a)
    {}
    }
    While overriding you just change the method behavior of the derived class.
    In Overloading method, two or more methods within the same class can be included with same name but different parameters. For example,
    Class A
    {
    class a()
    {}
    class a(int a)
    {}
    }
     
    softwebsolutions, Oct 7, 2011 IP
  3. gamblingmaster

    gamblingmaster Member

    Messages:
    113
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #3
    Overloading doesn't block inheritence from the superclass where as overridding blocks inheritence.JAVA does not support multiple inheritance
     
    gamblingmaster, Oct 14, 2011 IP