Whoever is "drumming on his desk" needs to come right after the comma.
We know that whoever is drumming is a he ("drumming on HIS desk"). • Mrs. Hobson isn't a "he," so A is out. • "Students" isn't a "he" either (because it's plural) so B is out. • "Exams" can't drum, so C is out. • That leaves D. Stewart is totally a dude, so that works fine.
The second sentence has a problem. The subject ("a lovely shade tree") comes right after the modifier, but the modifier DOESN'T refer to the lovely shade tree. That doesn't work. Right now the sentence is saying that the tree went for a long walk in the hot sun. So let's fix it:
• A is wrong, obviously. • B works. The subject coming right after the modifier is "I," and that's who went on the walk. • C repeats the error. It's still saying the tree went on a walk. • D is not only confusing; it's also just wrong. It still says that the tree went on a walk.
Your answer to the first question is D. The second question is B.