Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Field hiding and virtual dispatch

Hardware interview practice

Field hiding and virtual dispatch

MediumSystemVerilogSystemVerilog

What does the display print?

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

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
Choose one

Answer choices

  1. A. 1 1
  2. B. 2 1
  3. C. 2 2
  4. D. 1 2
Continue practicing

Related questions

SystemVerilogParameterized classes and static members→SystemVerilogPolymorphic deep copying→
asic.fyi · Learn silicon end to end.info@asic.fyi