Question

    In object-oriented programming, what type of

    polymorphism is achieved at runtime? 
    A Method Overloading Correct Answer Incorrect Answer
    B Method Overriding Correct Answer Incorrect Answer
    C Operator Overloading Correct Answer Incorrect Answer
    D Constructor Overloading Correct Answer Incorrect Answer
    E Function Overloading Correct Answer Incorrect Answer

    Solution

    Method Overriding is an example of runtime polymorphism. It occurs when a subclass provides a specific implementation of a method that is already defined in its superclass. At runtime, the method that gets executed depends on the object type (the subclass instance), not the reference type (the superclass reference), thus achieving polymorphism. This allows for flexibility in code, as the same method can behave differently depending on the object calling it. Why Other Options are Incorrect: A) Method Overloading: This is an example of compile-time polymorphism, not runtime polymorphism. C) Operator Overloading: While it is a form of polymorphism, it is resolved at compile time and is not applicable to runtime polymorphism. D) Constructor Overloading: Constructor overloading is a type of compile-time polymorphism, as the constructor to be invoked is determined at compile time. E) Function Overloading: Similar to method overloading, this is also resolved at compile time, not at runtime.

    Practice Next

    Relevant for Exams: