Question Marks Inside/Outside Quotation Marks and Parentheses

When the "?" is part of the quotation--it goes inside the quotation marks and is the terminal punctuation of the sentence:

When the "?" belongs to the sentence but not to the quoted passage, it goes outside the quotation marks and terminates the sentence:

When the "?" is part of the parenthetical text, it goes inside the parentheses, and when it is not, it goes outside them.