How do I fill a SystemVerilog Queue variable?
When I run your code on my simulators, I don't get any error message.  But, I also don't see any of the display messages either.  That is expected because neither of your foreach loops executes.  Since the queue is empty, the 1st foreach loop has nothing to loop over.  Therefore, nothing is added to the queue.  Similarly for the 2nd foreach.
You can use a for loop to add to the queue:
module queues;

int a[$];

initial begin
    for (int i=0; i&lt;100; i++) a.push_back(i);
    foreach(a[i]) $display(&quot;\tValue of a[%0d]=%0d&quot;,i , a[i]);
end
endmodule

This prints:
Value of a[0]=0
Value of a[1]=1
Value of a[2]=2
Value of a[3]=3
Value of a[4]=4
Value of a[5]=5

etc.
If you really want random data (as you mentioned), you could use something like $urandom:
for (int i=0; i&lt;100; i++) a.push_back($urandom);