SystemVerilog OOP Mastery · All levels

Factory Pattern: Polymorphism with Type and Instance Overrides: Interview Questions

Interview Questions for Factory Pattern: Polymorphism with Type and Instance Overrides.

Interview questions

Q1. Why is factory override considered polymorphism and not just string-based replacement?

Answer: Because code consumes base-class handles and virtual dispatch still applies; only concrete instantiation is deferred to runtime policy.

Q2. When would you prefer instance override over type override?

Answer: When experimenting on one subsystem path (for example one agent or monitor) while preserving baseline behavior elsewhere in the same test.

Q3. What is the first debug check when an override does not take effect?

Answer: Confirm creation uses `type_id::create` and that the override is set before that create call on the exact matching path/type.

Related topics