A question mark belongs at the end of a question. That may sound obvious, but sometimes sentences are treated like questions simply because they feature a clause containing 'question words' like How, When, Where, What, Which, Who, and so on. Another problem is that it is not always obvious where the question mark should go when you are writing about questions other people asked.
|Dialogue - Inside quotation marks||"What's your name?"|
|Quoting Dialogue - Inside quotation marks before Full Stop||When I met the girl, she asked, "What's your name?".|
|Question within a Question (and Quoting Dialogue) - Inside quotation marks in dialogue; and at the end of the overall sentence||When I meet the girl and she asks me, "What's your name?", what should I say?|
|Fully third person perspective - At end of sentence, closing off sentence||If she asks me what my name is, what should I say?|
Let's look at some examples and discuss them.
A question mark used in written dialogue or a direct quote:
"What's your name?"
This dialogue (or monologue, if only one person is speaking in the document) or reported speech might be find in a novel or short story, script or screenplay; but it can also be used in a thesis or essay. Note that the question mark is placed within the quotation marks.
A question mark used in a sentence quoting someone:
When I met the girl, she asked, "What's your name?".
This is a 'third-person perspective' (or 'reported speech' in ESL), in which the writer is referencing something the girl said. In this case, the question mark still belongs inside the quotation marks, because it was the girl who asked the question.
A question mark used in a sentence asking about a quotation:
When I meet the girl and she asks me, "What's your name?", what should I say?
Here, we have two questions, but the over-arching sentence is still in the third-person, as in the example above. The question mark remains within the girl's question, but there is another one at the end of the overall sentence. This is because the writer is asking a question within which the girl's question features. In this case, the writer's question mark acts in the place of a full stop, telling us either that the writer wants an answer, or that the question will be answered as the writing continues.
A question mark used in a sentence without any quotation marks:
If she asks me what my name is, what should I say?
Again, we have a third-person perspective, but the sentence is all in the third person with no intruding questions. In this case, the question mark belongs at the very end, closing off this stand-alone sentence.