• Post Reply Bookmark Topic Watch Topic
  • New Topic

Concurrency question  RSS feed

 
Vadim Vararu
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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?
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right, the result is either RunBeginEnd or BeginRunEnd. All you can say is that End is printed last.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 dry
  • B: You suffer flame burns
  • C: Your swimming costume comes off
  • D: You hit your head on an ocean liner
  • E: You are eaten by an Ichthyosaurus
  • The 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, eg
  • You get wet
  • All the girls think you are manly and attractive
  • All the men think you are feminine and attractive
  • You win a prize for diving
  • You 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
    Posts: 21135
    87
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 3185
    34
    Google App Engine Java Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Marshal
    Posts: 56546
    172
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Rob Prime wrote:. . . "all the girls are repulsed by your large tummy" . . .
    How did you know that?
     
    Rob Spoor
    Sheriff
    Posts: 21135
    87
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    who says I was talking about you
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!