Locks frequently as we power on at the boot screen itself

We recently got a HP Compaq 6715 from a friend it locks frequently as we power on at the boot screen itself. ( Shows the HP logo press f9 for Boot menu, F10 for Rom based Setup, F12 for Network Service Boot ) but after pressing any key it hangs. I have tried swapping the memory, doing a hard reset, resting the bios. Tell me how this problem can be fixed?
