I take a bit of a different approach toward illegal or inappropriate questions than a lot of authors or experts. For the past thirty-plus years, I've experienced thousands of companies and individuals in those companies who ask illegal questions. Most of the companies in this country have fewer than 100 people, and it may not come as a surprise that many hiring or interviewing authorities just don't have any idea what is legal and what isn't.
Some of them do it unknowingly and ignorantly, although that's really hard to believe. But it is true. Some of them do it because they're simply going to intentionally discriminate based on what they consider to be their prerogative. Some people ask illegal questions just to show interviewees that they're going to get away with it. It's all rather insane and stupid.
Many experts will tell you to flat out tell a prospective employer or hiring authority that a particular question is illegal. They will normally recommend that you tell the hiring authority that you don't have to answer that question, because it is illegal. I'm not going to tell you to do that. I'm going to tell you to do what you think is best about answering the question.
You may have a chance to be righteous and right and proceed to put some hiring or interviewing authority in his place by letting him know that he's breaking the law, or you can try to get a job. I assure you that if you make an interviewing or hiring authority uncomfortable by informing her that you know that the question she asked was illegal by saying something like, "That is an illegal question; I don't have to answer it," you won't get hired. Now, you may not really want to go to work for an organization or individual stupid enough ask obviously illegal questions. But if you need a job, and he or she has one, I certainly wouldn't recommend losing the opportunity by getting your nose out of joint over an illegal question.
Use your own judgment. You may want to consider answering the question, depending on the context in which it is asked. If you feel like someone is asking your age or your marital status because the person will probably use that information to eliminate you from consideration, you might say something in a startled, surprised, but very kind manner like, "Oh, goodness! I didn't know you could ask that question, but . . ." then answer the question in a way you think is appropriate.
You might also answer the question with a question, such as, "How does the answer to that question have an impact on my performance of the job or my ability to getting it?" This is a very nice way of saying, "That's an illegal question. It has nothing to do with my ability to do the job and I'm not going to answer it." If you feel that the question is being asked out of genuine interest and sincere empathy, like in a casual conversation after a formal interview, feel free to answer it in any manner that you wish.
Again, follow your instincts and the answer these questions in whatever way you are comfortable doing. I don't recommend "winning a battle" but "losing the war" over illegal questions. If you think it's appropriate to set someone straight about the illegal questions, feel free to do so. If the questions offend you, just don't go to work there.
Here's a list of the most common illegal or inappropriate questions:
Anything about the candidate's parents, spouses, nationality, ancestry or lineage
The name of next of kin
How a person might have acquired a second language
Any religious questions, political questions, religious holiday observances
Asking about a change of name or name of origin
Asking about marital status
Asking about the number, names, ages of children or dependents
Asking if a person has childcare for children
Asking if a person is planning on having a family
The branch of the military that a candidate has served in and the type of discharge
Asking about a candidate's preference to work with any identifiable "group," such as men, women, religious or ethnic group
Any questions about a person's native language or accent
Questions about organizations that the candidate might belong to
Asking candidates if they have ever filed a Worker's Compensation claim
Asking if a candidate has ever been arrested
Asking if the candidate has ever filed a claim against your company's insurance company