One obvious example would be if you had hired the interviewee in question. If so, it would be awfully difficult to demonstrate discrimination against them!
Don't get me wrong, it is a very bad idea to ask these questions. But it is not illegal, strictly speaking.