How a display statement getting displayed in a method of a class without object

Hi, I am trying basic oops concept, and i came across something new for me.


module wo_object();
   class a;
      function void display();
         $display("in class A ");
      endfunction
   endclass
   
   class b extends a;
     function void display();
          $display("in class b");
      endfunction
   endclass  
   initial begin
       a a1;
       b b1;
       a1.display();
       b1.display();
    end
   endmodule

i am getting output as
in class A
in class b. but what i expected is, it should give null object error. but no error? can anybody help me in understanding this.

and if I use virtual for method of a, then i am getting null object error as i expected. for a1.display();

help me.
Thanks in advance

In reply to cnu:
You may want to see Why is my code not failing when accessing non static method from not static class? | Verification Academy

The reason the virtual method fails is because the simulator needs to lookup the actual object instance type to know which method to call, and the object is null.

In reply to dave_59:

IEEE LRM 8.4 Objects wrote:

Accessing non-static members (see 8.9) or virtual methods (see 8.20) via a null object handle is illegal. The result of an illegal access via a null object is indeterminate, and implementations may issue an error.

In the above example, display() functions in both Class A & B are non-static members. According to the LRM, there should be an error. Can you please explain this?

In reply to srikanth_6313:
may issue an error” is not a requirement. “must or shall issue an error” is a requirement.