Final answer:
Bacteria employ restriction endonucleases as a defense mechanism to protect themselves from foreign DNA by cutting at specific unmethylated sequences, while their own DNA is protected by methylation.
Step-by-step explanation:
Bacteria protect themselves from foreign DNA through the action of restriction endonucleases. These enzymes recognize and cleave foreign DNA at specific sequences that are not methylated, effectively destroying genetic material that does not belong to the bacteria. The bacterial DNA is protected because it is methylated at these sequences by DNA methylase, thus the restriction enzymes do not cleave it. This system, known as a restriction modification system, is a crucial bacterial defense mechanism against elements such as invading viruses or other foreign DNA that could be harmful if incorporated into their genome.