If the charge (let me denote it as Q) inside is not in the centre of the spherical shell, it will exert non-radial force on the charges B of opposite sign on the inner surface of the shell. The charges B will distribute on the surface in such way that they will shield perfectly the charge Q, so the electric field in the metal will be zero. This is possible only if the highest density of surface charge will be at the part of the surface which is closest to the charge Q. Hence the charge Q will exert net force on the metallic shell, and by the principle of action and reaction, the same but opposite force will act on the charge Q. This force will pull the charge towards the wall of the shell. If Q is movable, it will approach the wall and become part of it. Then it will be sucked away to outer surface and will spread uniformly over it.
But how can charge be present at the inner surface of the shell? i mean wouldn't net electric field be 0 and hence q=0 inside the metallic part? so how can B exist at the inner surface? could you explain why it happens.
The electric field inside the metal is indeed 0, implying that the charge density is zero there too.
In order to make this possible, some charge B of opposite sign has to come from the metal to its inner surface and redistribute itself there so that the net electric force due to A and B in the interior of the metal is zero.
From another point of view, the positive charge A attracts equal amount of negative charge B as close as possible, that is, to the inner surface.
Zero density inside of the metal does not exclude that charge is present at the surface of the metal. In fact the charge density [itex]\sigma[/itex] and the normal component of the electric field obey the relation