The common assumption is that all God did was give him a "Who are you to question me" attitude but I, though I haven't read the whole thing yet; I feel God was more like when God was challanging Job he was trying to ask him "Where have I gone wrong on anything else, and where/when have you been absloutely right on everything?" Because wasn't Job questioning God not only for his state but the state of his entire creation? So when God faces Job he answers Job's feelings of the rest of the world, and afterwards he answer's Job's personal issues with the multiplied blessings...That makes God appear less whimsical or even sadistic, right?
I think that God was assuring Job that while Job was of the dust It was God that knew Job and He knew him better than he knew himself.
In this story God is like that Marine Seargent that is yelling at his recruit to get over that wall. The Seargent knows that this training can possibly save the recruits life in a battle. The recruit hates his drill master until he gets over the wall and then it dawns on him Old Sarge had his well being in mind all along.
The apostle James sums up the whole theology of the book of Job when he says, "We... have seen the outcome fo the Lord's dealings, that the Lord is full of compassion and is merciful" (Jas 5:11).