holes all day. Most of the time he gets it right. Without that kind of experience, and none of us have it, we have to rely on other methods which are fallible.
One method I have seen, yet sadly neglected to capture on camera, is dowsing. This lady came in and picked up all the pullets in a tank one at a time, and held a string with a needle tied to it over them. She muttered something about getting hens this time and refused to trust in the wizened old dude; well, us too for that matter, which is actually understandable.
A much more interesting method a couple of sane customers shared involved inspecting the wing feathers. Pullets will have much more developed or uneven wing feathers than cockerels at the same age.
Now, if you are not dealing with day old chicks, you can observe behavior. For example, the customer that tossed the cockerel in with the pullets was fairly easy to find because he had a different posture than the other pullets--but this is only because he was a little older than the pullets. If you watch day old chicks, they all pretty much act the same, but it does not take notice male behavior, such as strutting and other postures.