There's a widespread but incorrect belief that these sorts of questions are illegal. The act of asking them actually is not illegal. What can be illegal is rejecting you based on your answers to them.
Read the complete post here, to learn what a job seeker can do to his or her advantage when faced with one of these uncomfortable questions.
Thank you, Askamanager, for clarifying this point!