There are some subtleties to each of the following sentences (and you should say can here, not cannot). I have described the interpretation I make of them (even though the inference I describe in italics is not explicit or even what anyone else would agree with).
All the examples are OK, and don't seem to have any special interaction with the sentence structure.
The question is too difficult for any student in the class to answer.
Every student in the class finds the question too hard, even the best student.
The question is too difficult for the student in the class to answer.
The class only has one student, and the question is hard for them. maybe the question is easy, and the student weak - there is no information to decide
Also, if the student has been identified previously as now being in a group class and we know there is more than one in the class, the reference here could be to that individual, unable to answer because they are in the class (rather than one-to-one). This ought to be clear in the context of the phrase
The question is too difficult for the students in the class to answer.
As a group, the students can't answer the question. it was probably asked of them as a team exercise rather than for them to answer individually