With no nuclei, there can be no sexual reproduction in the prokaryotes, but there is an exchange of DNA. In one type, conjugation, conjugation (“sex”) pili (bridges of cytoplasm) form between cells, and some DNA is passed from the donor to the recipient cell.
In bacterial communities some DNA exists outside of cells, presumably left when the cells die, or more probably, excreted into the environment by living cells. This “free” DNA is picked up bacterial cells in another kind of gene exchange, transformation.
A third type of exchange— transduction—results when bacteriophages (special kinds of viruses) bring into bacterial cells the DNA from their previous viral host. (Researchers in biotechnology use the same method to introduce new genes into host organisms.)
Random changes in the DNA are common. These mutations of the genetic code alter the response of the individual to its environment. If the mutation is deleterious, the individual dies, but favorable mutations spread rapidly as the cells divide repeatedly and often.