Hardware interview practice
Field hiding and virtual dispatch
What does the display print?
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()); endChoose one
Answer choices
- A. 1 1
- B. 2 1
- C. 2 2
- D. 1 2
