Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Shallow copying

Hardware interview practice

Shallow copying

EasySystemVerilogSystemVerilog

What value is 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 Box; int v; endclass
class C; Box box; endclass
C a, b;
initial begin
  a = new;
  a.box = new;
  a.box.v = 1;
  b = new a;
  b.box.v = 9;
  $display("%0d", a.box.v);
end
Choose one

Answer choices

  1. A. 1
  2. B. 9
  3. C. 0
  4. D. x
Continue practicing

Related questions

SystemVerilogVirtual methods→SystemVerilogDowncasting→
asic.fyi · Learn silicon end to end.info@asic.fyi