Need clarification on static method and non static method

In reply to Somu:
task static foo();

endtask

Is illegal inside a class. If you are not getting an syntax error, you are using a tool that does not support the current version of the SystemVerilog standard. SystemVerilog made this syntax illegal for the exact doubt you are having now. There is never a good reason to use this syntax outside a class, but SystemVerilog is required to be backward compatible with Verilog.

Class members (like j in your example) are not automatic variables. They are dynamically allocated when you call the class constructor
new()
. Automatic variable are allocated upon entry to a block like a task or function.

When you put the
static
keyword in front of a class method, it has nothing to do with the lifetime of the method - it is always automatic.

You should take a look at my short course on SystemVerilog OOP for more information of static methods.