He already knew the answer, so he was a little surprised when the Hat talked to him instead of just announcing it. Indeed, he might have startled rather visibly, had there not been magic in place to prevent people from doing that.