Can we implement dynamic polymorphism with instance variables or data members | Code Decode

Поделиться
HTML-код
  • Опубликовано: 18 окт 2024
  • Polymorphism is one of the OOPs feature that allows us to perform a single action in different ways.
    Udemy Course of Code Decode on Microservice k8s AWS CICD link:
    openinapp.co/u...
    Course Description Video :
    yt.openinapp.c...
    Method overriding is one of the ways in which Java supports Runtime Polymorphism. Dynamic method dispatch is the mechanism by which a call to an overridden method is resolved at run time, rather than compile time.
    if a superclass contains a method that is overridden by a subclass, then when different types of objects are referred to through a superclass reference variable, different versions of the method are executed.
    In this video we find an answer with live example for Runtime Polymorphism or dynamic polymorphism with Data Members
    In Java, we can override methods only, not the variables(data members), so runtime polymorphism or dynamic polymorphism cannot be achieved by instance variables or data members.
    The example actually shows dynamic method dispatch program in java. what happens if we try to apply runtime polymorphism in oop concept on instance variables or data members of java class.
    This video has dynamic polymorphism in java example. Live demo on how it behaves with instance variables or data members

Комментарии • 10