polymorphism in java

I just have a little confusion that regarding polymorphism that is method overloading and overriding really a part of polymorphism becoz somewhere I get to know that method overloading is compile-time polymorphism and somewhere i read that overloading and overriding is actually not at all a part of polymorphism,so plz clarify the distinction that is it really that method overloading and overriding are a part of polymorphism or not.

Replies

  • Anoop Kumar
    Anoop Kumar
    Yes.. Method overloading is compile time as we are passing different argument.
     public void getEmpName(int empId) {
        ......
    }
    
    public void getEmpName(String empName) {
        ......
    }
    
    public void getEmpName(int empId, String empName) {
        ......
    }
    and in method overriding is same signature from parent and subclass. so, if you use interface based programming while execution only it will be decided as runtime.

    Now coming to your question, I see stackoverflow discussion but IMO overloading is polymorphism. If you see the implementation of System.out.println method there are 10 implementation. Now as a user just use the method and compare with the definition of polymorphism. If it is fulfilling the criteria then yes, overloading is a polymorphism.
     polymorphism means that some code or operations or objects behave differently in different contexts.
    #-Link-Snipped-#.
    Some say overloading is ad-hoc but as per definition, if code is behaving differently at different scenario then its polymorphism.
  • micheal john
    micheal john
    Method overload is compile time and
    Method overriding is run-time polymorphsim

You are reading an archived discussion.

Related Posts

i would like to know in brief the procedure for carrying out markings for placing of pillars?
i am working on a project of making race car for some international competition . According to rules , the noise level should be less than 110 db . I...
If you thought you could spill a cup of coffee on your keyboard in a furious state of mind after reading an online troll and clean it up later thinking...
I was reading additional material about Samsung's research about 5X transmission speeds and came across an article that said soon Samsung's stock would jump. I've read about it multiple times...
Even though the folks at Facebook’s Oculus VR are still working out the kinks associated with the public launch of their maiden virtual reality headset, it did not prevent them...