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

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • 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
      • Same Name, Different Prototype: Hiding Not Overriding
      • 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
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Virtual Method Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. OOP & Testbench Puzzles
  4. Virtual Method Puzzles
  5. super Method Call in Override Chain
On this page

    VLSI DV Interview PuzzlesAll levels

    super Method Call in Override Chain

    A derived override calls `super.report()`. Predict final string and explain call chain.

    Puzzle

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

    A derived override calls `super.report()`. Predict final string and explain call chain.

    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
    24
    25
    class base_r;
      virtual function string report();
        return "B";
      endfunction
    endclass
    
    class mid_r extends base_r;
      function string report();
        return {"M-", super.report()};
      endfunction
    endclass
    
    class ext_r extends mid_r;
      function string report();
        return {"E-", super.report()};
      endfunction
    endclass
    
    initial begin
      base_r h;
      ext_r  e;
      e = new();
      h = e;
      $display("%s", h.report());
    end

    Hint

    `super` is lexical (next class in inheritance chain), not dynamic back to most-derived.

    Step-by-step solution

    Diagram
    1) Dynamic dispatch picks `ext_r::report` for `h.report()`.
    2) `ext_r` calls `super.report()` => `mid_r::report`.
    3) `mid_r` calls its `super.report()` => `base_r::report`.
    4) Concatenation yields `E-M-B`.

    Answer

    Answer: Final output is `E-M-B`; dynamic entry is most-derived, then explicit `super` walks up one lexical level each call.

    How this was checked

    Checked by running the code in Verilator 5; the printed output supports the answer above. The shown code run in Verilator: each super.report() walks one level up the chain.

    Why candidates get it wrong

    `super.report()` is a lexical call to the parent class's implementation, never a new dynamic dispatch, so it cannot loop back to `ext_r`. Candidates who think it re-dispatches expect infinite recursion.

    Interviewer follow-up

    How would behavior change if `mid_r::report` were declared non-virtual? Model answer: it would not change. Once a method is virtual in the base, every same-prototype method in a derived class is virtual whether or not the keyword is repeated, so the output is still `E-M-B`. (Verified in Verilator.)

    Say it out loud

    The output is E-M-B. The call dispatches dynamically to the most derived report. Then each level calls super, which walks up exactly one level at a time, from extended to mid to base. The trap is thinking super skips to the base directly. I would check that every level really calls super and that report is virtual.

    Related topics

    • extends and super

    • Virtual dispatch

    • Back to Virtual Method Puzzles

    • OOP & Testbench Puzzles section

    Previous

    47 / 293

    Next: Parameterized Class Puzzles

    Up next

    Up nextParameterized Class Puzzles

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • Non-Virtual vs Virtual Through Base Handle
    • Missing super.new with Required Base Args
    • Virtual Call from Base Constructor