Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Parameterized classes and static members

Hardware interview practice

Parameterized classes and static members

MediumSystemVerilogSystemVerilog

What values are printed?

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 Counter #(type T = int);
  static int count = 0;
  function new(); count++; endfunction
endclass
Counter #(int) a, b; Counter #(byte) c;
initial begin
  a = new; b = new; c = new;
  $display("%0d %0d", Counter#(int)::count, Counter#(byte)::count);
end
Choose one

Answer choices

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

Related questions

SystemVerilogField hiding and virtual dispatch→SystemVerilogPolymorphic deep copying→
asic.fyi · Learn silicon end to end.info@asic.fyi