The genes to be resistant to an antibiotic already exist in the bacteria's genes. Those whose phenotypes are resistant to the antibiotic will survive the antibiotic which kills the other non-antibiotic-resistant bacteria. The surviving bacteria will then asexually reproduce, producing more antibiotic-resistant bacteria.