In other cases, the interviewer is trying to figure out the candidate’s commitments outside of work. People with school aged children occasionally take time off when their kids are sick or the school is closed. They may have restricted schedules due to child care arrangements.
How to answer it:
If you don’t have kids, you’re best off just saying so to avoid any awkwardness with the interview. If your spouse works from home or stays home with kids, you could simply say that you have kids but your spouse stays at home and handles the kid duties.
If you don’t want to answer the question, you could try avoiding it. One way is to change the subject. Say something like “ah kids, I think parents are the most underappreciated people in the world.”
I’ve seen some experts suggest that you simply lie and say whatever the interviewer is looking to hear. Their rationale is that since the question is illegal, your answer can’t be used against you even after you get the job. I personally don’t agree with this and believe that you’re better off explaining to the interviewer that the question is illegal rather than lying.