@joyR
Still playing with options for the court scenario, maybe contempt is an option.
You're missing something, two words.
Sustained, overruled.
Let's say the defense lawyer in a case asks a question of the witness. Just because the prosecution says, 'Objection', does NOT automatically mean the objection is sustained (meaning the witness cannot answer, or if the witness answers, the jury will be ordered to disregard the statement). If the judge feels that the question is relevant, then he will order the objection overruled, and the witness can answer the question. If the defense attorney feels the facts or testimony are specifically relevant and key to his case, he can also plead with the judge in chambers, away from the jury, that the testimony must be heard.
The witness himself is never going to get on the stand without having gone over his testimony in advance with the defense lawyer. He'd NEVER be called, otherwise. Your case where the witness would ask that kind of question could never happen in a criminal or civil trial with competent (or not so competent) attorneys present on both sides.
When a witness is called to the stand and upon being sworn in to tell the truth, the whole truth, and nothing but the truth, and then seems to have an issue doing so or answering questions, they are also allowed to be treated as a hostile witness. Thus (and presuming with your use of prosecution and defense that this is a criminal trial, because otherwise it's plaintiff and defendant and is a civil trial), if they know the prosecutor isn't going to ask the right questions, the defense can cross examine the witness to get the testimony needed.
Simple scene:
Defense: "Mr. Smith, what did you see on the night of July 4th?"
Prosecution: "Objection!"
Defense: "Your honor, the testimony of Mr. Smith is key to showing what my client did that evening."
Judge: "Overruled, you may answer, Mr. Smith."
The witness isn't going to be saying squat on his own, it's the defense lawyer who has to push it.