Why do Hamsters Bite?

Like alot of creatures, hamsters tend to bite when they feel threatened because it is one of their only forms of protection. If they are biting their cages, it could just be boredom.