Understand the definition of a compound: A compound is a substance formed when two or more different elements chemically bond together in fixed proportions.
Examine each option to determine if it consists of different elements chemically bonded:
H2O (water) consists of hydrogen and oxygen atoms chemically bonded, so it is a compound.
CO2 (carbon dioxide) consists of carbon and oxygen atoms chemically bonded, so it is a compound.
NaCl (sodium chloride) consists of sodium and chlorine atoms chemically bonded, so it is a compound.
O2 (oxygen gas) consists of only one type of element (oxygen) bonded to itself, so it is a molecule but not a compound.