How do we determine what distant planets, stars etc are made of? I remember this being covered somewhat back in school and I have casually read about it. I know it involves inferring from spectral analysis what physical properties an object may have right?
Though I was stumped when trying to give a quick explanation to some friends who ridiculed the idea astronomers can know for certain what composition a distant object has.
I'd love to personally understand what different test are involved but also a quick rebuttal to my friends. It's depressing when people belittle science just because they don't understand something. :/
 A: The major tool in investigating the composition of an astronomical body is spectroscopy.  This technique makes use of the fact that a body composing certain elements/compounds will shine more brightly(or less) at particular wavelengths.  The pattern of 'lines' taken by a spectrograph can then be used to infer the original composition.  This technique is used on Earth as well for calibration and has a pedigree of over 100 years.
A famous example is the discovery of helium, it's existence was discovered in the Sun before on Earth!  This was done by analysing the solar spectrum, and noticing particular dark bands.  These dark bands were where light was being absorbed by the Helium in the solar atmosphere.
The composition of extra solar planet should be taken with a pinch of salt, the science is very new and uses instruments not designed for the task.  Keep an eye out for new missions such as ECHO which might fly in the next 5 to 10 years...
Apart from stellar spectra we can also observe something called the 21cm line.  This a particular emission of Hydrogen, and it helps map out enormous clouds of hydrogen.  The science of astronomical compositions is quite battle hardened, it has survived many years of experiment and undergone much refinement.
