Hi, I understand the concept/definition of polymorphism. But
what does the term "runtime polymorphism" mean? I was asked to
define it during a technical interview. I gave a guy vanilla
definition of polymorphism, but he insisted on runtime. Did I
miss a new buzzword while I was sick with the flu last week or
something like that?
LP,
Like most computer science definitions, "polymorphism" is pretty well
defined when used in academic settings, but completely twisted
and abused when used in a commercial context.
A good academic definition can be found here:
http://en.wikipedia.org/wiki/Polymorphism_(computer_science)
C#'s inheritance mechanism is implemented by the compiler using
runtime polymorphism (i.e. virtual methods, dynamic runtime lookup
tables, late binding, etc...)
However, there are some people on the net who use the term "compile
time polymorphism" to refer to C#'s method overloading, like this
guy:
http://www.dickbaldwin.com/csharp/Cs000112.htm
(I personally have never heard the word "polymorphism" used to
describe method overloading.)
Other languages, like C++ and Ada, have a different kind of "compile
time polymorphism". In this case, a compiler can perform early
binding at compile time on at least some of the virtual methods that
are called in the code. Those virtual methods can then be called as
fast as non-virtual methods since there is no runtime lookup to
perform.
Google on the phrases "runtime polymorphism" and "compile time
polymorphism" to get more info.