Counting primes in given interval
Rethinking it

The obvious change that leaps out at me immediately is to make your list of primes into an object or even class field.  Then you don't need to recreate your primes each time.  You'd create it the first time.  Later you'd just extend it.  An object field would be better programming practice, but a class field would work for this problem.  

You might even read in all the input first and then create the primes list once for all of them.  Or just build it to a million before processing the input.  Of course, that would fail if they have some tests where passing means not calculating all million.  Given your current algorithm, it would be easy enough to calculate all the primes from 0 to 1000 beforehand.  

Consider holding the primes in a NavigableSet.  Because what you want to know is how many primes are in a range.  So you could replace 

            System.out.println(segmentedSieve(l,r)) ;


with 

            System.out.println(primes.subSet(l, r).size());


That counts the primes in the set [l, r) if primes is a NavigableSet holding at least all primes less than r.  

If you need to count [l, r] or (l, r), you would use the longer version with booleans for inclusiveness.  

Specific advice


    static void sieveOfEratosthenes(int l,int r,List&lt;Integer&gt; prime)



You never call this with l as anything but 0.  So you might as well say 

    static void sieveOfEratosthenes(int r, List&lt;Integer&gt; prime)


Then you can get rid of the check in the loop:  


                if(i&gt;=l)



That's always true if l is zero and i is at least 2.  You don't have to check it.  

You don't need the counter variable.  As is, it's equal to prime.size() and you never use it.  Eliminating it saves an operation.  The compiler might do that for you, but you don't need it.  


                for(int j=i*2;i*i&lt;=r &amp;&amp; j&lt;r+1;j+=i)



This could be 

                for (int j = i*i; j &lt;= r; j += i)


You only need to check from i*i.  Anything smaller than that would already be marked.  For example, you already marked everything divisible by 2, so i*2 would be marked for all i greater than or equal to 1.  

You only needed to check i*i&lt;=r once.  This still does that check, as the first iteration j equals i*i.  

The j&lt;r+1 and j &lt;= r are equivalent if j and r are integers.