When different atoms join together, they are called a compound. Compounds are made of molecules (so molecules could be an alternate answer, but not all molecules are compounds)
They have 6 electron in their outer orbital. That means they want 2 electrons to be stable. Since metals have the tendency to give electron oxygen receives 2 electrons. The answer is -2