| Author |
Concurrency question
|
Vadim Vararu
Ranch Hand
Joined: Jan 03, 2009
Posts: 147
|
|
A) Compilation fails.
B) An exception is thrown at runtime.
C) "BeginRunEnd" is printed.
D) "BeginEndRun" is printed.
E) "BeginEnd" is printed.
The correct answer is C, but i don't know why. I think it can be "BeginRunEnd", but also "RunBeginEnd" in case thread "a" succeds to print "Run" before the "main" thread prints "Begin". Do you have idea why the only correct answer (according to the site) is C?
|
If you think you've done too much, usually it means you've done too few.
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2929
|
|
|
Please QuoteYourSources
|
Mohamed Sanaulla | My Blog
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You are right, the result is either RunBeginEnd or BeginRunEnd. All you can say is that End is printed last.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
On a multiple-choice exam, one must find one "correct" answer and four "incorrect" answers. "C" is correct, but the other four are incorrect. It is a bit like the following question about swimming-pools:
What might happen if you dive into a swimming-pool full of cold water?A: You remain dryB: You suffer flame burnsC: Your swimming costume comes offD: You hit your head on an ocean linerE: You are eaten by an IchthyosaurusThe answer is obviously C, because you cannot stay dry or suffer flames burns in a swimming-pool, and ocean liners or Ichthyosauri are never found in swimming-pools. There are all sorts of other possible right answers, egYou get wetAll the girls think you are manly and attractiveAll the men think you are feminine and attractiveYou win a prize for divingYou swim away . . . but those are not given as possibilities. So "your swimming custome comes off" is the only possible correct answer available for that question.
Yes, I have known it happen, once, when I was at school.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Campbell Ritchie wrote:All the girls think you are manly and attractive
I think you mean "all the girls are repulsed by your large tummy"
|
 |
Mohamed Sanaulla
Bartender
Joined: Sep 08, 2007
Posts: 2929
|
|
Interesting analogies coming from Campbell these days Or is it the usual?
But agree- with MCQs we need not worry about the answers which are not given as options. But always better to read the question carefully as you may end up selecting the right answer, but you were asked to select the wrong answers
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
Rob Prime wrote:. . . "all the girls are repulsed by your large tummy" . . .
How did you know that?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
who says I was talking about you
|
 |
 |
|
|
subject: Concurrency question
|
|
|