Correct option is C
Early binding occurs at
compile-time, where the method to be called is resolved during compilation. It is faster as there is no overhead for method resolution at runtime. Late binding, on the other hand, occurs at
runtime, offering flexibility by allowing dynamic method resolution, which is essential for achieving
polymorphism.
Example:
·
Early Binding: Non-virtual methods in C++ or methods without virtual or override keywords in Java/C# are examples of early binding.
·
Late Binding: Methods marked as virtual in C++ or override in Java/C# enable late binding for runtime resolution.
Important Key Points:
1.
Early binding occurs when the compiler determines the method to call at compile time (e.g., static methods, overloaded methods).
2.
Late binding occurs when the method to call is determined at runtime, typically through virtual functions or interfaces.
3.
Polymorphism relies on late binding to dynamically resolve method calls for derived objects.
Knowledge Booster:
·
Early binding refers to runtime method resolution: Incorrect; early binding is resolved during compilation.
·
Late binding is achieved through the final keyword in Java: Incorrect; final prevents method overriding and disables late binding.
·
Late binding does not support polymorphism: Incorrect; late binding is crucial for achieving polymorphism.
·
Early binding can only occur with abstract classes: Incorrect; early binding is unrelated to abstract classes and applies to static or non-virtual methods.