📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    Which of the following best describes the control flow

    when a method in a subclass overrides a method in its superclass, and an object of the subclass is referred to by a superclass reference, then the overridden method is called? 
    A The superclass method is executed due to static binding. Correct Answer Incorrect Answer
    B The subclass method is executed due to dynamic polymorphism (runtime binding). Correct Answer Incorrect Answer
    C A compilation error occurs because of method ambiguity. Correct Answer Incorrect Answer
    D Both superclass and subclass methods are executed sequentially. Correct Answer Incorrect Answer

    Solution

    This is a core concept of polymorphism in OOP. When an overridden method is called on an object referenced by a superclass type, the actual method executed is determined at runtime based on the actual type of the object, not the reference type. This is known as dynamic method dispatch or runtime polymorphism.

    Practice Next
    ask-question