a) If B can prove that A dishonestly/fraudulently adopted the idea then A will not be entitled to the patent. B can always get the patent revoked, if granted. You may refer to grounds of opposition and revocation in the Indian Patent Act.
b) I agree with Mr. Mahapatra on second part of your query. Let me draw your attention to the following:
EPO examination practice provides us some guidance for such cases. I quote “should two applications of the same effective date be received from two different applicants, each must be allowed to proceed as though the other did not exist.”
Since US still follows first to invent system it can be easily decided. In US there is something called as Interference Proceedings to deal with such cases. You need to have well documented records to prove conception of your invention. Conception is complete when no more than routine work is need to carry out the invention.
?? I do not find any specific provision either in the patent act or draft manual which can give us some guidance. I would be pleased if someone can throw light on this (patent office practice or any case law).