Any member of a group of atomic or nuclear species all of which have the same mass number that is the total number of protons and neutrons, is known as isobars.
Protons and neutrons i.e. the atomic mass of the element is known as nucleons.
Therefore, species A and B have different protons but the same number of nucleons. So, they are isobars.
While X and Y have the same number of protons but a different number of nucleons, so they are isotopes.