Viruses are a type of malware that copies itself once it goes into your computer, but it needs contacts to spread. It can be very dangerous to your computer.
Trojan horses are a type of virus that makes it seem legitimate, but ends up being a virus that can open a back door for a hacker.
Spyware is a type of malware that secretly sneaks around and steals your personal information. It saves what you type and sends it to a person. Can be very bad if you type in your personal information.
How to avoid
Firewall, restricts what comes in and what comes out. antivirus software, makes sure what you're clicking on.