A positive charge q is placed in a spherical cavity made in a positively charged sphere. The centers of sphere and cavity are displaced by a small distance →l. Force on charge q is:
Electric field inside solid sphere is given as: E=ρ→r3ϵ∘
where ρ is charge density and →r is position vector of point P inside sphere w.r.t. it's center.
Using superposition principle for resulting electric field:
E=Esphere−Ecavity
=ρ→rp/sphere3ϵ∘−ρ→rp/cavity3ϵ∘
=ρ(→rp/sphere−→rp/cavity)3ϵ∘
=ρ→l3ϵ∘
Thus the force will be parallel to the direction of displacement →l.