In my physics class we were analyzing a scenario where a charge has been placed inside the cavity of a conducting material like this:
What my teacher did was to assume a Gaussian surface in the conducting region, and a charge $x$ to be present in that region (along with the already-present $+q$ charge), and then apply Gauss's law. He told us that the electric field inside a conducting medium must always be $0$, and thus according to Gauss's law we get that $x=-q$. Thus a negative charge of magnitude $q$ develops on the walls of the cavity and a charge $-x=+q$ develops on the outer surface of the conductor (by conservation of charge). Thus the final diagram becomes like:
My teacher had demonstrated the fact that the electric field is always $0$ inside a conductor by using Gauss's law as follows:
My confusion is that in that scenario (in image 3), no charge was present in the conducting body, so how could we generalize that result? If we try doing the same with this scenario (in image 1), $Q_{inside S} \neq 0$ so we cannot predict the electric field. So my question is, how do you go about predicting the electric field in this case?