Back to the 2026 paper

Module 6: Advanced Topics

20262m

Dynamic method dispatch is primarily used to implement:
(i) Lexical analysis
(ii) Constant folding
(iii) Runtime polymorphism
(iv) Register allocation

Worked SolutionAI Assisted

Answer: (iii) Runtime polymorphism

Explanation

Dynamic method dispatch selects which overridden method to call based on the actual (run-time) type of the object, not the declared type of the reference.

Compilers implement it with a virtual method table (vtable): each object carries a hidden pointer to its class's vtable, and a virtual call becomes an indirect call through a fixed slot index.

Animal a = new Dog();
a.speak();   // Dog.speak() is chosen at run time

This is exactly runtime (dynamic) polymorphism. It has nothing to do with lexical analysis, constant folding or register allocation.

(iii) Runtime polymorphism\boxed{\text{(iii) Runtime polymorphism}}

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.