Hardware interview practice
Virtual methods
What is printed?
Starting point
Question code
class B;
virtual function string kind(); return "B"; endfunction
endclass
class D extends B;
function string kind(); return "D"; endfunction
endclass
B b; D d = new;
initial begin b = d; $display("%s", b.kind()); endChoose one
Answer choices
- A. B
- B. A compile error because B cannot reference D
- C. An empty string
- D. D
