This course has already ended.

Late (Dynamic) Binding

A subclass can implement a function it inherit anew with an implementation of its own. In C++ the possibility to do this is offered by defining the function in the base class as virtual (keyword virtual). In Java the functions in the interface are by default such that the subclass can implement them the way it sees fit. This and polymorphism mean that the implementation that needs to be called for the function can be lower down the inheritance hierarchy. The compiler cannot in these situations necessarily determine from which class the implementation should be called. The decision is made at runtime instead. This is called late or dynamic binding. Late binding makes it possible that the same function call code can call functions of different objects. The function call behaves differents depending on which class’ object it was called to. Java uses late binding for all public class methods not marked final.

Polymorphism and late binding (duration 11:04)

Posting submission...