Dynamic Binding MCQs: 8 Solved Questions and 4 Runtime Dispatch Drills

Test whether you can separate reference type, actual object type, overloading, and overriding, then explain four runtime dispatch cases in your own words.

KnowledgeGate Team

Exam prep & CS education

Updated 31 Oct 20267 min read
Dynamic Binding MCQs: 8 Solved Questions and 4 Runtime Dispatch Drills

In P x = new Q(), the reference type is P, but the actual object is Q. Overriding, virtual functions, Java overloading, and runtime dispatch traces all ask the same question: which type controls this call? Commit before checking each answer, then continue through Coding & DSA.

1. Build the dynamic-binding decision table first

Decision table contrasts static and dynamic method selection for Base and Derived calls.

Static binding resolves the target from compile-time information. Dynamic binding defers an eligible overridden-method choice until runtime and uses the actual object's implementation. Inheritance alone does not make every call dynamic.

Call

Virtual/dynamic dispatch?

Actual object

Selected method

Printed value

Base* ptr = &d; ptr->display();

yes

Derived

Derived::display

Derived Display

Base* ptr = &d; ptr->display();

no

Derived

Base::display

Base Display

P x = new Q(); x.f(1);

yes

Q

Q.f(int)

2

Overloads show(int) and show(String) are selected from argument type at compile time. If Animal.sound() is overridden and an Animal reference holds a Dog, runtime dispatch selects Dog.sound(). Static vs Dynamic Binding MCQs handles scope, aliasing, and general binding time. OOP method dispatch instead depends on overriding, overload selection, virtual calls, and runtime method choice.

2. Dynamic Binding MCQs 1-2: overriding and virtual functions

Question 1: Beltron Programmer 2025, Computer Science, Shift-1

Dynamic binding works with which of the following OOP features?

  • A. Data hiding

  • B. Operator overloading

  • C. Constructor overloading

  • D. Function overriding

Answer: D. Function overriding. Suppose Shape.draw() is overridden by Circle.draw(). When a base reference points to a Circle, dynamic dispatch selects Circle.draw() at runtime. Data hiding controls access, while operator and constructor overloading use compile-time signatures. This is runtime polymorphism through overriding. The runtime object decides which override handles the call.

Question 2: Kendriya Vidyalaya Sangathan 2018, Computer Science

Use of a virtual function implies _____.

  • A. Overloading

  • B. Overriding

  • C. Static binding

  • D. Dynamic binding

Answer: D. A virtual call through Base* ptr = &d reaches Derived::display() because d is derived.

3. Dynamic Binding MCQs 3-4: runtime polymorphism in C++

C++ dispatch needs an inheritance relationship, an overridable virtual function, and a call through a base pointer or reference. Remove any one of those elements and this runtime-dispatch pattern fails.

Question 3: CDAC CCAT 2025

Virtual functions in C++ are used to implement:

  • A. Compile-time polymorphism

  • B. Runtime polymorphism

  • C. Multiple inheritance

  • D. Static binding

Answer: B. Runtime polymorphism. A virtual call through a base pointer or reference can select a derived override at runtime. The virtual keyword does not create multiple inheritance, and static binding fixes the target before runtime dispatch.

Question 4: UGC NET 2016, Computer Science

In C++, polymorphism requires:

  • A. Inheritance only

  • B. Virtual functions only

  • C. References only

  • D. Inheritance, virtual functions and references

Answer: D. Inheritance, virtual functions and references. In the expected framing, inheritance supplies the base-derived relationship, a virtual member makes runtime selection eligible, and a base reference or pointer reaches the derived object. Any one element alone is insufficient for this dispatch pattern.

4. Dynamic Binding MCQs 5-6: runtime choice versus Java overloading

Question 5: Beltron Programmer 2025, Computer Science, Shift-2

Which of the following options best describes dynamic binding in object-oriented programming?

  • A. It enables the decision of which method to invoke to be made during runtime based on the actual object.

  • B. It refers to associating a variable with a data type at the time of compilation.

  • C. It restricts object behaviour to predefined compile-time rules.

  • D. It statically assigns methods to function calls using compile-time type information.

Answer: A. Runtime selection uses the actual object. In Animal a = new Dog(), eligible dispatch selects Dog.sound().

Question 6: IBPS 2025

Which statement is correct about method binding in Java?

  • A. Dynamic binding is used for method overloading, which is resolved at runtime

  • B. Static binding is used for method overriding and is more flexible than dynamic binding

  • C. Static binding is faster than dynamic binding, and dynamic binding is not applicable to method overloading

  • D. Both static and dynamic binding are resolved at runtime

  • E. Method overloading in Java is resolved using dynamic dispatch

Answer: C. Java chooses print(7) or print("seven") from compile-time types; eligible overriding is runtime. The speed wording is a textbook comparison. Use the Java course.

5. Dynamic Binding MCQs 7-8: missing polymorphism and a complete dispatch trace

Question 7: Hexaware and CoCubes 2024

Read the following program and identify which OOP concept from the options is not used in it.

cpp
class A
{
    int x;
public:
    void print(){ cout << "hello"; }
};

class B: public A
{
    int y;
public:
    void assign(int a){ y = a; }
};
  • A. Polymorphism

  • B. Encapsulation

  • C. Inheritance

  • D. Abstraction

Answer: A. Polymorphism. Class B inherits from A, and the classes package data with operations. However, B neither overrides print() nor invokes it through a virtual base-class call, so the program contains no runtime-polymorphic dispatch.

Question 8: GATE 2003, Computer Science

Consider the following class definitions in a hypothetical Object Oriented language that supports inheritance and uses dynamic binding. The language should not be assumed to be either Java or C++, though the syntax is similar.

Code
Class P
{
    void f(int i)
    {
        print(i);
    }
}

Class Q subclass of P
{
    void f(int i)
    {
        print(2*i);
    }
}

Now consider the following program fragment:

Code
P x = new Q();
Q y = new Q();
P z = new Q();
x.f(1); ((P)y).f(1); z.f(1); 

Here ((P)y) denotes a typecast of y to P. The output produced by executing the above program fragment will be

  • A. 1 2 1

  • B. 2 1 1

  • C. 2 1 2

  • D. 2 2 2

Answer: D. 2 2 2. x holds a Q, so Q.f(1) gives 2 * 1 = 2. Casting y to P does not change its Q object, so it prints 2. The Q held by z also prints 2. The sequence is 2 2 2. When an individual question page is unavailable, revisit the same concepts in the Dynamic Binding lesson.

Three dispatch traces show x, cast y, and z retaining runtime type Q, each selecting Q.f(1) and producing output 2 2 2.

6. Written drills 9-10: binding time and the virtual call

For Questions 9-12, write a one- or two-sentence answer before reading the response, including exact output when code is present.

Question 9

Differentiate between compile-time binding and dynamic binding in object-oriented programming. Explain how they differ regarding execution time and the mechanisms used to achieve them.

Binding

Resolution time

Selection basis

Typical mechanism

Polymorphism effect

Compile-time binding

Before execution

Declared types and signatures

Overload selection

Fixes the target statically

Dynamic binding

During execution

Actual object type

Eligible overridden virtual method

Enables runtime polymorphism

For example, overload selection uses the Shape signature. Eligible dispatch on an actual Circle selects Circle.draw().

Question 10

A programmer implements runtime polymorphism using dynamic binding as shown below:

cpp
#include <iostream>
using namespace std;

class Base {
public:
    virtual void display() {
        cout << "Base Display ";
    }
};

class Derived : public Base {
public:
    void display() {
        cout << "Derived Display ";
    }
};

int main() {
    Base* ptr;
    Derived d;
    ptr = &d;
    ptr->display();
    return 0;
}

Determine the output produced and justify how dynamic binding influences the function call behavior.

Response: The text is Derived Display, then one trailing space. ptr is a Base* holding &d. Since display() is virtual, dispatch selects Derived::display(). Practise through the C++ Programming course.

7. Written drills 11-12: choose the dispatch case and remove virtual

Question 11

A developer is evaluating two function binding mechanisms in an object-oriented system:

- Case A: Function calls are resolved at compile time based on the reference type.

- Case B: Function calls are resolved at runtime based on the actual object type using virtual functions.

Evaluate which case correctly represents dynamic binding in a polymorphic system. Justify the selection based on function resolution and runtime behavior.

Response: Case B is dynamic binding because runtime virtual dispatch follows the actual object. Case A is static binding because it uses compile-time reference information. B alone is incomplete.

Question 12

A developer attempts to implement dynamic binding in the following program:

cpp
#include <iostream>
using namespace std;

class Base {
public:
    void display() {
        cout << "Base Display ";
    }
};

class Derived : public Base {
public:
    void display() {
        cout << "Derived Display ";
    }
};

int main() {
    Base* ptr;
    Derived d;
    ptr = &d;
    ptr->display();
    return 0;
}

Determine whether dynamic binding is achieved. Identify the reason for the observed behavior and justify the outcome based on binding mechanisms.

Response: Dynamic binding is not achieved. It prints Base Display, then one trailing space, because Base::display() is not virtual, so the Base* call is static. In Question 10, virtual selects Derived::display().

8. Diagnose the misses and choose the next practice step

Treat your MCQ score as a guide to what to practise next, not as an official cutoff. With 7-8 correct, explain both code traces aloud and move on. With 5-6, rebuild the decision table. With 0-4, revise overriding, virtual functions, and static versus dynamic selection before retesting.

For Questions 9-12, check whether every response names when selection happens, what information selects the method, and the exact output where code is present. Reattempt them after 48 hours without viewing the table. Use Java for overload and override practice, and C++ Programming for virtual-function practice. Choose the route matching your weakest trace, then solve the set again without notes.