No, Coffee isn't any cure for absentmindedness. He need good sleep after his class. He need to relax not to force himself to be awake by drinking coffee.
Edit: I'm sure, during his computer study subject he is attentive and when they informed him about holiday, Subjects like Maths or Chemistry...