The key of C major was discussed earlier. A piece of music that uses notes from the C major scale is said to be in the key of C. Similarly a piece of music that uses notes from the G major scale is said to be in the key of G major. Music in the key of G will contain F sharp (F#) notes.
Instead of writing a sharp sign before every F note on the staff, it is easier to write just one sharp sign after each clef. This means that all the F notes on the staff are played as F#, even though there is no sharp sign written before them. This is called a key signature.
The C major scale contains no sharps or flats, therefore the key signature for the key of C major contains no sharps or flats.
The G major scale contains one sharp, F#, therefore the key signature for the key of G major contains one sharp, F#.