Does Your Boss Have The Right To Ask If You Are Planning to Get Pregnant?

I took a course on Human Resource Manangement and the topic came up about whether or not an employer has the right to ask a potential employee if she plans on getting pregnant in the near future. This leads to the possibility of a woman not getting hired if she is planning to have a baby in the next few years. There were arguments to support this saying that maturnity leave costs the company money and all kinds of stuff. During the discussion one of the female students jumped in saying, "How can you penalize us for getting pregnant, when you [men] get us pregnant?" So I want you all to think about this and give me your opinions on this issue.