* Adverb: When used to express hope or desire, "hopefully" modifies a verb or clause. For example: "Hopefully, the weather will be good for the picnic."
* Interjection: When used as a standalone word to express hope, "hopefully" is an interjection. For example: "Hopefully!"
Therefore, the part of speech depends on its function in the sentence.