I have tried the code given here http://twitter4j.org/en/code-examples.html This worked but I am getting only a limited number of tweets. Is there a limit on the number tweets per execution? I tried executing the program twice, and I got the same result.
Regarding the link you gave, Is it a REST call(webservice call) where you are sending the request in XML format and getting the response in XML?
There is indeed a limitation for tweets. As far as I have seen from experimentation, the number of tweets returned by any query is at most 1500 (not sure if this maximum is accurate). There is also a time-limitation of (again from experimentation) about a week.
As for the second link, you don't send XML, just simple HTTP parameters. The first link shows which parameters it can accept.