Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ298
Page ↗
Q298DVDesignASIC interview problem

Field hiding and virtual dispatch

TechniquesSystemVerilogAdvanced OOP
DifficultyMedium
TopicSV
LanguageSystemVerilog
Format4 choices
01

Problem

What does the display print?

Class declarationSystemVerilog
class B;
  int x = 1;
  virtual function int f(); return x; endfunction
endclass
class D extends B;
  int x = 2;
  function int f(); return x; endfunction
endclass
B b; D d = new;
initial begin b = d; $display("%0d %0d", b.x, b.f()); end
02

Answer choices (4)