occurs when a character’s words mean the opposite of their literal meaning.​

1 answer

The literary device being referred to in this question is called "verbal irony".