The question mark can appear inside quotation marks or outside. When the entire phrase is a question, the question mark goes outside. With a quotation that is a question, the question mark goes inside the quotation marks. Let us provide examples.
In the following example, the quotation is a question. Did the teacher say "You have to study harder"? The teacher's exact words were "You have to study harder". As a result, the question mark goes outside the quotation marks.
However, in this example, the quotation contains a question. He whispered "Do you need this book?" Since the quotation contains a question, the question mark must go inside the quotation marks.
With quotations that contain a question, the question mark is written inside the quotation marks. However, with quotations that do not contain a question, the question mark is written outside. The placement of the question mark is important because it conveys a difference in meaning.