Yeah I've seen that in a movie. It works as long as you can escape before the prof grabs you to find out who you are
My friend who cheated his way through HS devised a good plan: don't write the exam at all, just put it in your pocket. Once time is up, leave the class, and make sure to say something to the prof, so they see that you were there and think you wrote the exam. Then write the essay at home. Plant the essay in the prof's office somewhere, and then later ask him/her why you didn't get a mark. They'll remember you were there, look around the office, and hopefully think it was their fault, and give you your mark.
It didn't really work for my friend because she said he just had to write it again after she said she didn't receive an exam from him
"Jack, will you call me, if you're able?"
"I've got your phone number written, in the back of my Bible."