A Unique Case (Ahadith 1151 - 1152)

Narrated Ibn 'Umar:
The Prophet looked at the people of the well (the well in which the bodies of the pagans killed in the Battle of Badr were thrown) and said, "Have you found true what your Lord promised you?" Somebody said to him, "You are addressing dead people." He replied, "You do not hear better than they but they cannot reply."
Narrated 'Aisha:
The Prophet said, "They now realize that what I used to tell them was the truth. "And Allah said, 'Verily! You cannot make the dead to hear (i.e. benefit them, and similarly the disbelievers) nor can you make the deaf hear. (27.80).
It's true that the dead cannot hear anything that the living say.  Allaah says (interpretation of the meanings): 
“..but you cannot make hear those who are in graves” [Faatir 35:22]
“So verily, you (O Muhammad) cannot make the dead to hear” [al-Room 30:52]
With regard to the incident mentioned in the above Ahadith, it is to be understood that this was a unique case, where Allaah brought them back to life so that His Prophet (peace and blessings of Allaah be upon him) might rebuke them and humiliate them.
The relevant point here is that Allaah caused the people in the well to hear the words of His Prophet (peace and blessings of Allaah be upon him), so that they might be humiliated. But it is not correct to deduce from this hadeeth that the dead can hear everything, because this applied only to the people in the well. Some scholars made an exception and said that the dead can hear the salaam, but this is a view for which clear sound evidence is lacking.