Well, I know *one* question we're gonna delete in the next version
There won't be a question *quite* this fuzzy on the exam. I will say that in the intro to the exam, it does say that you are to assume that anything you do NOT see is working normally, as expected. In other words, you are to imagine that if there is a variable, it has been properly initialized, unless otherwise stated.
So, that was our intent when we said, "activeT" -- so that you would KNOW that the thread you were joining with had in fact NOT yet completed. But this is pretty weak (and doesn't explain the InterruptedException issue -- which I'll get to in a moment).
Most of the time in the *real* exam, we tried to be explicit about that, by saying things like:
Given <stuff>
and assuming that <variable> has been properly initialized...
Still, all of the programming exams (SCBCD,
SCJP, SCWCD) do use variables that have not been *demonstrated* to have been properly initialized, but yet you are required to assume that they do in fact hold what they claim to, either by their name, or even by context. So if I were taking a Sun exam, I would definitely have assumed that activeT was an active thread. But I wouldn't worry, because as I said, the real exam doesn't have anything that ambiguous. They've all been long since 'pruned' from the 1.4
test, now that so many people have taken it!
However, that still doesn't really work for this question, because the way it is worded does not give enough information with respect to the InterruptedException. It would have to be changed to something like:
"Assuming an InterruptedException is not (and has not been) thrown, which of the three will cause the thread to leave the running state?"
So, you're all correct -- it's just a poorly-worded question, so it really doesn't work. If i were to completely change the wording, what do you think about this (I know it's awkward, but we don't have much to work with on edits)
"Given that no InterruptedExceptions are (or have been) thrown, and that activeT is a Thread which is still Runnable, which of these guarantee that a thread will leave the running state?"
I think the main point we were trying to test is whether you understood that yield() is only a suggestion, not a guarantee of anything.
Anyway, thanks and sheesh-- I hope that you will at least consider our bad question a 'learning opportunity'
Then we can pretend that, why yes, that was our intent all along!
Cheers and thanks for the help!! And sorry for the confusion. The folks who've taken the exam are right -- if you know the content, the real exam questions are not ambiguous. But do remember the, "Assume everything else you don't see is working correctly". Because remember, virtually ANYTHING on the exam could fail if you were to imagine things like, "Well, they didn't actually SAY that the JVM or compiler were configured properly into their OS..." Or, they didn't SAY that they used a proper editor -- like, they didn't actually state that they didn't write this in RTF..." So, you could take it to the extreme unless you assme that "everything else is working..."
The only time I've seen this really become an issue is with Assertions, where the question (although I think we may have fixed all of these), might not explicitly say whether assertions are enabled. But if the question says, "Which of these will cause assertions to run only for classes within..." you are to assume, "if assertions are enabled."
The exam is tricky, but we didn't try to deliberately catch you on things like that.
If we want to test you on whether you know that assertions aren't enabled by default, then the question will explicitly ask you if assertions are enabled or disabled by default!
-Kathy