The tonic is the 1st note in the scale. For example, in the G major scale, G is the tonic.
The subdominant note is the fourth scale degree of any key, for example in C major the subdominant note is F since the scale goes C D E F G A B C.
The tonic of the D major scale is D. The tonic is the first note of a diatonic scale. The tonic is more commonly called the "root."
The fifth note of C major scale is G. The fifth note of any scale is always called the dominant.
G major
f#
C
The dominant note is the 5th note in the scale. ie: in a C Major scale, G is the dominant note. The dominant is represented by the Roman Numeral "V" in music.
The keyword "g" in the C major scale represents the seventh note, which creates a sense of tension and leads back to the first note, completing the scale.
B major's submediant note is g#
F sharp
The interval between the notes D and G is a perfect fourth.