SystemVerilog OOP Mastery · All levels
Abstract Classes with `virtual class`: Interview Questions
Interview Questions for Abstract Classes with `virtual class`.
Interview questions
Q1. Why would you mark a class `virtual` even if it currently has no pure virtual methods?
Answer: To encode design intent that the class is a framework scaffold, not a runtime object. It prevents direct construction and keeps extension points explicit for future protocol variants.
Q2. What is a practical verification benefit of abstract base classes?
Answer: They centralize shared instrumentation and lifecycle logic while forcing concrete subclasses to supply protocol-specific behavior, reducing duplicated code and accidental inconsistency.