To prevent an object from passing through the surface of another object

Ok there may be some obvious solution that am not so sure of. But how do I prevent an object from intercepting the surface of another object. For example if am modelling a cup on a table is there a way to constrain the cup to just the surface of the table so it doesn’t look like the cup is sinking through the surface?

I think this video might help you !

ok thanks a million