The flats and sharps in a key signature occur in a particular order.
B E A D G C F
Sharps are the reverse of the flats:
F C G D A E B
A key signature may contain either flats or sharps, but not both.
The key signatures for major scales are on the staff below:
To determine the key of a flat key signature: look at the second to last
flat. This will be the key.
For example: If there are three flats in the key signature; Bb, Eb, and
Ab: the second to last flat is E-flat. The key is E-flat major.
The only exception is F major which has one flat.
For sharp keys: Take the last sharp and go up one half step and one letter
For example: If the key signature has four sharps (F#, C#, G#, D#) the
last sharp is D#: go up one half step and one letter name to E- the key
is E major.