Some of the bolts (fenders & hinges, for example) are attached before painting, so they're painted at the same time as the panels if you're painting the car similar to the factory method. For the bolts that you paint and then install later, depending on size/fastener torque, masking tape around the hex, or plastic inserts in the tool socket, work pretty well. Invariably some get touched up. I always make sure I have more than enough fasteners as spares, in case one gets garfed more than I want to touch up.