An object becomes charged when its particles exchange electrons with other particles. When something loses an electron, it becomes positively charged, and when it gains an electron, it becomes negatively charged. The charge is determined by the number of electrons versus the number of protons.
Objects can be charged by friction, which occurs when two objects rub against one another and exchange electrons. For example, when a person in leather shoes walks on a wool carpet, the leather loses electrons to the carpet. As a result, the person becomes positively charged. Whether an object gains or loses electrons depends on its electronegativity, or degree of attraction to electrons.