posted 18 years ago
I have a question about this code example (TwoThreads class). It comes from K&B's book, page 756.
Given the above code which letters will eventually appear somewhere in the output? (choose all that apply.)
A. A
B. B
C. C
D. D
E. E
F. F
G. The answer cannot be reliably determined
H. The code does not compile
the answer is:
A, C, D, E, F.
I don't understand why B is not a correct answer, as is it not possible that a InterruptedException (or any other random exception) occurs, therefore B might be printed? Or are these sort of things ignored in the exam. I thought the answer would be G, as it cannot be relibly determined if B will be output or not.
Plus, the book says that on the exam, the number of options for an answer will be given. In this case, does this mean that in the exam they will tell us 5 answers are correct? That would make this question infinitely more obvious.
Thanks for your time
Sok