Here's why:
* Barium readily loses two electrons to achieve a stable electron configuration, becoming a positively charged ion (Ba²⁺).
* Oxygen readily gains two electrons to achieve a stable electron configuration, becoming a negatively charged ion (O²⁻).
* The electrostatic attraction between the positively charged barium ion and the negatively charged oxygen ion forms the ionic bond.
The resulting compound is barium oxide (BaO).