Self-defense or private defense is a countermeasure that involves defending oneself, one's property or the well-being of another from harm.
Physical self defense is the use of physical force to counter an immediate threat of violence. Such force can be either armed or unarmed. In either case, the chances of success depend on a large number of parameters, related to the severity of the threat on one hand, but also on the mental and physical preparedness of the defender.
Many styles of martial arts are practiced for self-defense or include self-defense techniques. Some styles train primarily for self-defense, while other martial/combat sports can be effectively applied for self-defense. To provide more practical self-defense, many modern day martial arts schools now use a combination of martial arts styles and techniques, and will often customize self-defense training to suit the participants' lifestyles, occupations, age groups and gender, and physical and mental capabilities. Now one of the most popular to learn, is a martial art called krav-maga specifically for self defense scenarios.
Note that self defense laws vary from country to country so one thing that might be true where you live is not necessarily true elsewhere. A quick Google search can lead to several legal sites. If you are interested in legal aspects of self defense, please see a defense lawyer in your jurisdiction as asking for legal advice from strangers on the Internet is unlikely to yield good results.