Run-time polymorphism is achieved by method overriding.
Method overriding allows us to have methods in the base and derived classes with the same name and the same parameters.
By runtime polymorphism, we can point to any derived class from the object of the base class at runtime that shows the ability of runtime binding.
Through the reference variable of a base class, the determination of the method to be called is based on the object being referred to by reference variable.
Compiler would not be aware whether the method is available for overriding the functionality or not. So compiler would not give any error at compile time. At runtime, it will be decided which method to call and if there is no method at runtime, it will give an error.
Share this:
2 thoughts on “OOP – What is dynamic or runtime polymorphism?”
Hello.This post was really motivating, especially since I was searching for thoughts on this subject last Sunday.
Hello.This post was really motivating, especially since I was searching for thoughts on this subject last Sunday.
When some one searches for his required thing, therefore he/she needs to be available that in detail, therefore that thing is maintained over here.|