If you opt for it, then yes of course, abstinence-only sex education is a sure way to stop ten pregnancy.
Similarly, if you opt to change your lifestyle and start living healthier, and follow through, it will work.
If someone tries to force you, of course it will fail (in both of these cases). There is no way to stop someone else from being fat. We can only change ourselves.