Because surnames are passed down from father to son in many cultures (patrilineal), and Y-chromosomes (Y-DNA) are passed from father to son with a predictable rate of mutation, people with the same surname can use genealogical DNA testing to determine if they share a common ancestor within recent history.
Some labs even store the submitted samples for a number of years, enabling additional tests to be performed as they become available.
The Y chromosome has been studied intensely and variations have been divided into Human Y-chromosome DNA haplogroups, based upon the results of the number of alleles in certain positions called markers.
These "markers" have been chosen for their demonstrated ability to predict the haplogroup of the tested individual.
This had allowed Y-STR database websites such as Ybase and Ysearch (both now defunct) to convert scores from several companies and find matches within their database for submitted results.