• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Concurrency question  RSS feed

 
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?
 
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources
 
Sheriff
Posts: 21463
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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.
 
Marshal
Posts: 61693
193
  • 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: 21463
    97
    Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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: 61693
    193
    • 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: 21463
    97
    Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    who says I was talking about you
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!