One of the cool things about the major scale (or the Ionian mode as it used to be called) is that there's one interval that only occurs once in each scale - the tritone between the fifth and the seventh degree. What this means is that you only have to hear this interval in order to know which key you're in. This interval forms half the notes in the dominant seventh chord, which is the chord that usually comes immediately before the tonic chord in the final cadence, providing you with a maximally unequivocal statement of the piece's overall key or tonality.

!