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. Signature Mismatch Prevents Override

VLSI DV Interview Puzzles · All levels

Signature Mismatch Prevents Override

Why does base implementation run even though derived defines a method with the same name?

On this page

    Puzzle

    Difficulty: Medium · Puzzle 4 of 6 · Topic: Virtual Method Puzzles

    Why does base implementation run even though derived defines a method with the same name?

    Code

    design.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    class base_chk;
      virtual function int score(int e);
        return e + 1;
      endfunction
    endclass
    
    class ext_chk extends base_chk;
      function int score(int e, int bonus = 10);
        return e + bonus;
      endfunction
    endclass
    
    initial begin
      base_chk h = new ext_chk();
      $display("%0d", h.score(5));
    end

    Hint

    Override requires compatible prototype, not just same method name.

    Step-by-step solution

    Diagram
    1) `base_chk::score` expects one argument; derived declaration has different signature.
    2) This does not override the base virtual slot used by calls through base handle.
    3) Call `h.score(5)` resolves to base implementation and prints 6.
    4) Fix by matching prototype exactly in derived and handling bonus internally.

    Answer

    Answer: Because method signatures differ, derived method does not override the base virtual method; base version executes through base handle.

    Why candidates get it wrong

    Interviewers use this to catch name-based reasoning instead of signature-based override rules.

    Interviewer follow-up

    Would adding `virtual` keyword on derived method change behavior if signature still mismatches?

    Related topics

    • Back to Virtual Method Puzzles

    • OOP & Testbench Puzzles section

    Previous

    39 / 210

    Next: Template Method with Non-Virtual Wrapper

    Up next

    Up nextTemplate Method with Non-Virtual Wrapper

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Non-Virtual vs Virtual Through Base Handle
    • Missing super.new with Required Base Args
    • super Method Call in Override Chain