Now when b.start() is called ,the ThreadB enters into synchronised block and has a lock of the object b; then how can main thread enters into synchronised(b) and wait method is called?
This is not entirely correct. The main thread merely starts the thread B with the the call to the start() method. It does not call the run() method -- thread B does that.
In starting a thread, it will schedule the thread to run, which may or may not run immediately. In fact, in most cases, the answer is that it will not be running. For you, as a developer, you should design your code to make no assumptions. You should design your code to work regardless if thread B or the main thread runs first.