I feel sorry for the student. This is going to be another of those "someone makes a dumb faux pas" stories that's copy-pasted all over the internet for everyone to jump on their high horse about.
I actually don't feel sorry for the student. I wish I'd had a professor smack some sense into me earlier. For me, it took a tough supervisor a few years out of school to get the message through. The sad part is that I had it together better than many others I've met even then.
Getting your dumb faux pas chewed out in such a manner is a great thing - you get the learning experience, but you don't get the ugly consequences that often come with that; i.e., this anonymous posting vs. a public failure that will stay on your record forever, a firing from a job or a break in important personal relationship. And, by the way, all these three things were quite likely with the 'default behaviour' that the student showed, and hopefully this event will allow him/her to achieve better results in future.
I think the point is that there's a less disrespectful way of finding out which class you should take ie. talking to other students, online research, reading course descriptions, etc.
Of course we don't have context, but walking into a class an hour in seems like it's fairly presumptuous.