Polymorphism vs Overriding vs Overloading

前端 未结 21 2806
北恋
北恋 2020-11-22 01:10

In terms of Java, when someone asks:

what is polymorphism?

Would overloading or overriding be

21条回答
  •  遇见更好的自我
    2020-11-22 01:32

    Polymorphism is more likely as far as it's meaning is concerned ... to OVERRIDING in java

    It's all about different behavior of the SAME object in different situations(In programming way ... you can call different ARGUMENTS)

    I think the example below will help you to understand ... Though it's not PURE java code ...

         public void See(Friend)
         {
            System.out.println("Talk");
         }
    

    But if we change the ARGUMENT ... the BEHAVIOR will be changed ...

         public void See(Enemy)
         {
            System.out.println("Run");
         }
    

    The Person(here the "Object") is same ...

提交回复
热议问题