ACtE03 · Chapter 3Programming & Applications🏛️ Past Licensure QuestionID: 767b325f
Virtual functions in C++ are primarily utilized to achieve:
Virtual functions in C++ are primarily utilized to achieve:
Multiple Choice Options
- A
Compile-time polymorphism
- B
Lexical scope binding
- C✓ Correct Option
Runtime polymorphism (dynamic dispatch)
- D
Hardware interrupt redirection
Detailed Technical Solution & Explanation
Virtual functions enable runtime polymorphism. When a member function is declared virtual, calls through base class pointers or references are resolved dynamically at runtime based on the actual object type pointed to, via the virtual table (vtable).
Option Analysis:
•
Option A (Compile-time polymorphism): Achieved through function overloading and templates.
•
Option B (Lexical scope binding): Static compile-time scoping mechanism.
•
Option C (Runtime polymorphism (dynamic dispatch)): Correct. Virtual functions provide dynamic method resolution at runtime.
•
Option D (Hardware interrupt redirection): Low-level OS/CPU mechanism.
Reference: Mock Test 04NEC Licensure Syllabus