How memory will be allocated for a variable inside class function(without creating object)

class A;
  function int display();
    int i=10;
    return(i);
   endfunction
endclass

module check();
  A a;
  int x;
  initial begin
    x=a.display();
    $display("x=%0d", x);
  end
endmodule

In the above code, I didnt create any object for class A, with the help of handle I have called the function display() and its returning i value to x(i = 10). My question is how the memory will be allocated for ‘i’ without new() construct or is it just printing i value? Please justify and correct me if I am wrong.

In reply to aiswaryanatarajan:

The variable i has an automatic lifetime. It gets allocated when calling the function.

Also see Why is my code not failing when accessing non static method from not static class? | Verification Academy

In reply to aiswaryanatarajan:

That code looks wrong. I’m correctly getting a segfault:

Error-[NOA] Null object access
testbench.sv, 14
The object at dereference depth 0 is being used before it was
constructed/allocated.
Please make sure that the object is allocated before using it.