How is a missile lock detected?
To add some data to Matthew's answer: 
Anti aircraft missiles come in basically 4 types (some others have been tried but aren't in common use).


Active radar homing
Passive radar homing
Infrared homing
Laser guided





Active radar homing has a radar in the missile sending out signals. Those signals can be detected and classified by the target aircraft.
Passive radar homing has a receiver in the missile reacting to specific signals bounced off of the target by the launching system. These too can be detected and classified by the target aircraft.
Infrared missiles are completely passive and can't be detected this way.
Laser guided missiles are like passive radar homing missiles, except they react to reflections of a laser beam rather than a radar signal. These too can of course be detected and classified with appropriate sensors.


There have been some attempts at detecting missiles by their own infrared signature, typically their engine exhaust. But this is problematic because most of that is of course blocked from the missile's target by the missile body, and also many missiles will spend a lot of their flight towards the target in an unpowered glide state, thus not having a hot engine exhaust.

Other systems generally can't be detected by the target either. Think optical guidance using a radio link with the missile (while you might be able to detect the link, you can't readily know what it's doing or that you're the target if you do recognise it as a missile guidance link).

Optical guidance using control wires is not generally used with anti-aircraft missiles, but sometimes anti-tank missiles using these systems are used against slow flying aircraft. These are utterly impossible to detect.