Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • OOP & Testbench Puzzles25
    • Handle and Copy Puzzles
    • Virtual Method Puzzles
      • Non-Virtual vs Virtual Through Base Handle
      • Missing super.new with Required Base Args
      • Virtual Call from Base Constructor
      • Signature Mismatch Prevents Override
      • Template Method with Non-Virtual Wrapper
      • super Method Call in Override Chain
    • Parameterized Class Puzzles
    • Factory Override Puzzles
    • OOP & Testbench Puzzles: Tricky Q&A
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • Interview Prep: Puzzle Rounds5
  • DV Puzzle Cheatsheet
Loading lesson

‹Virtual Method Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. OOP & Testbench Puzzles
  4. Virtual Method Puzzles
  5. Non-Virtual vs Virtual Through Base Handle

VLSI DV Interview Puzzles · All levels

Non-Virtual vs Virtual Through Base Handle

A framework stores derived objects in base handles. Predict output and explain why only one method dispatches to derived.

On this page

    Puzzle

    Difficulty: Easy · Puzzle 1 of 6 · Topic: Virtual Method Puzzles

    A framework stores derived objects in base handles. Predict output and explain why only one method dispatches to derived.

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    class checker_base;
      function string mode();
        return "BASE";
      endfunction
      virtual function string detail();
        return "base-detail";
      endfunction
    endclass
    
    class checker_ext extends checker_base;
      function string mode();
        return "EXT";
      endfunction
      function string detail();
        return "ext-detail";
      endfunction
    endclass
    
    initial begin
      checker_base c;
      c = new checker_ext();
      $display("mode=%s detail=%s", c.mode(), c.detail());
    end

    Hint

    Dispatch behavior is determined by virtual-ness in the base declaration.

    Step-by-step solution

    Diagram
    1) `mode()` is non-virtual in base, so call binds statically to `checker_base::mode`.
    2) `detail()` is virtual in base, so call dispatches dynamically to `checker_ext::detail`.
    3) Output becomes `mode=BASE detail=ext-detail`.

    Answer

    Answer: Output is `mode=BASE detail=ext-detail`; non-virtual methods bind to static handle type while virtual methods use runtime object type.

    Why candidates get it wrong

    Declaring method in derived does not create polymorphism unless base declaration is virtual.

    Interviewer follow-up

    If `mode` is made virtual only in derived, does behavior change through `checker_base` handle?

    Related topics

    • Back to Virtual Method Puzzles

    • OOP & Testbench Puzzles section

    Previous

    36 / 210

    Next: Missing super.new with Required Base Args

    Up next

    Up nextMissing super.new with Required Base Args

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Virtual Call from Base Constructor
    • Signature Mismatch Prevents Override
    • Template Method with Non-Virtual Wrapper