These statements are not equivalent because the first could be true without the second being true, e.g., if the teacher simply keeps mum about the upcoming exam.1) The surprise exam will occur.2) The class knows that the surprise exam will occur.
At any rate, he is making out a tension between the two statements. If his logic is right, then if the second statement is true, the first is compelled to be false, which, as mentioned, is absurd. So either his logic is flawed or else we must conclude, on pain of absurdity, that the second statement cannot be true, after all. But at no stage of the argument does the first statement ever come under threat.1) The surprise exam will occur.2) The class knows that the surprise exam will occur.