Answer:
It depends on the type of substance. Typically if both have adequate valence electrons to get to 8. (Law of Octaves)
The different types of bonds (ionic, covalent, metallic) occur as the reaction of elections.
Ionic occurs when a valence electron is transferred.
Covalent occurs when valence electrons are shared.
Metallic bonding occurs when electrons are free to move around and move through respective metals.