Polymorphism in java | Run Time binding Compile time binding late binding | up casting down casting

Publicado el: 15 febrero 2022
en el canal de: Muhammad Umar Farooq
488
8

#Polymorphism #LateBinding #Upcasting #Downcasting

Polymorphism literally means “of multiple shapes/forms” and in the context of OOP,
polymorphism means “having multiple behaviors”.
Look at the example of Inheritance in video

Normally, when we want to create an object of a class we call its constructor. To
create an object of class Person we write
Person per = new Person ( );
There is nothing strange in the above line of code as we create objects of a class by
calling its any of the available constructor.
BUT, polymorphism allows us also to write the following line of code
Person per = new Employee ( );
Don’t be surprised; just revisit the concept of inheritance i.e. is a relationship. Since
we can say that Employee is a Person. It means that a variable of type Person can
point to an object of type Employee. That’s what we have translated above in the
form of code. What do you think about the following line?
Person ahmad = new Teacher ( );
Employee usman = new Manager ( );

These are 100 percent correct and rightly so, because Teacher is a Person as well as
Manager is an Employee.


En esta página del sitio puede ver el video en línea Polymorphism in java | Run Time binding Compile time binding late binding | up casting down casting de Duración hora minuto segunda en buena calidad , que subió el usuario Muhammad Umar Farooq 15 febrero 2022, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 488 veces y le gustó 8 a los espectadores. Disfruta viendo!