Exit polls take a sample survey of people post voting with a sample size of 1000 per venue (total size 100k for full elections). They then use the data from that to extrapolate general sentiment and voting trends within a population, per ethnicity, gender, sexual orientation etc.
Thanks!