Another thing I realized recently about homework assignments is that, in a lot of cases, they are configured so that they can be easily graded too. This goes for things like specifying variable and method names, to actually telling students how to structure their code.
The instructor isn't neccesarily teaching the students how to solve 'real world' problems so much as they are teaching them how to write code in that language that will compile. They are showing them the tip of the iceberg and leaving the rest of it for more advanced classes where there will, most likely, be fewer students and the teacher can give more personalized instruction.
As far as it goes, most of the homework questions I see are of one of two things:
class path and environment issues, or
the student waited until the last minute now doesn't know where to start so they post an 'URGENT' post with the entire assignment in it followed by - 'how would you do this?'