A student answered exam question with a method she's working on her thesis. What should she do to keep the authorship her own?
Your friend's concern is pretty far-fetched.  Researchers aren't usually in the habit of mining student exams for research ideas.  Even if the professor was inspired by it, it's quite likely he would want to discuss it with the student anyway, and the thesis issue could be brought up at that time.

But if she is still worried, there's an extremely simple solution: just tell him about it.  Send a short email mentioning that the exam question turned out to be related to her thesis work, and that her answer is based on her research work so far; and that if it's something that interests him, she would be happy to meet and tell him more.  (But it would be a good idea to check with her advisor before that meeting, in case there is some information which is proprietary or confidential or otherwise should not be shared at all.)

Now he knows that it is part of her research, and the feared scenario is averted.