We study the inside of stars using a method called spectroscopy. When you take a spectrum of a star, the light that centers your telescope is split up into individual wavelengths. Each element has particular wavelengths that it appears at. For example, Hydrogen appears at a 6563 A (that means 0.0000006563 meters!) along with a set of other wavelengths.
So by taking a spectrum, we can see what elements (Hydrogen, Helium, Oxygen, Nitrogren) are present. By looking at how strong the lines are relative to each other, we can figure out how much Oxygen and other elements there are relative to Hydorgen. This tells us about the inner structure of the star.
With regards to finding stars that are about to explode, there are so many of them exploding every night that we struggle to observe them all! We can figure out which ones will explode beforehand by looking at their spectra and estimating how much fuel they have left.