The intense gravity from a black hole or a neutron star will pull in dust particles from a surrounding cloud of dust or a nearby star. As the particles speed up and heat up, they emit x-rays. So the x-rays don't come directly from the black hole or neutron star, but from its effect on the dust around it. Rotating stars Many stars rotate around each other, much as the planets orbit our Sun. When astronomers see a star circling around something, but they cannot see what that something is, they suspect a black hole or a neutron star.
Astronomers use a technique called gravity lensing to search for black holes and neutron stars.
When a very massive object passes between a star and the earth, the object acts like a lens and focuses light rays from the star on the Earth. This causes the star to brighten. The answer comes from Albert Einstein, who proved in 1919 that light follows in the path of the bent time and space which is warped due to the gravitational force of a massive object. Einstein predicted that a star positioned behind the sun would be visible during a total eclipse. The Sun bent the light rays coming from the star and made it appear next to the sun.