Based on the key signature, the melody in the score above is in the key of D major. Key signature is the set of sharps or flats placed at the beginning of a musical staff to indicate the key of the music. In this score, there are two sharps placed at the beginning of the staff, which are located on the lines of F# and C#. This key signature matches the key of D major, which has F# and C# as its two sharps.
Additionally, the final note of the piece is a D, which further confirms that the piece is in the key of D major.