The best solution is to speak with the teacher and ask for clarification, but you are here instead.
Image 1 shows a shaft coupled to something like a pulley with a machine key. I have to assume the key is taking the load of the spinning shafts. The material and size of the key needs to be selected with some care. Too small, and it could shear. Wrong material, and it could cause corrosion.
The next two images show a shaft supported on both ends by bearings. It is not clear, but does image A show the keys pressed tight against the bearings? If so, any expansion of the shaft will tend to push the keys out and loosen them.
Image B does not appear to allow expansion of the shaft, but expansion of the housing is allowed. I guess it depends on the design and what it does, but I'd allow some clearance for the shaft as well. No clearance and the bearings will get pressed out, or the shaft will buckle...
Seriously, the teacher would be happy to discuss this with you. Nobody ever speaks to the teacher outside of class. Show an interest in what they are teaching and you'll do well!
Thanks man! I know that! Actually it is internet and I wanted some comments from real great engineers like you and so I could get a better idea of it!
By the way, I can clarify it here that these examples are coming from this book here:
I have attached a second picture showing these examples in the book too and you can see the original explanations for them given in the book :)