Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Surprisingly no error...

 
sonir shah
Ranch Hand
Posts: 435
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Options:
A: The code does not compile due to line //1.
B: The code does not compile due to line //2.
C: The code does not compile due to line //3.
D: The code does not compile due to line //4.
E: There is nothing wrong with the code.
Ans: E)Nothing wrong with the code..
My question is can we implement Thread.yield() is called when is no start() and no run ().Should it compile? And Surprisingly , the output printed is "false"!!!
Can any one explain me?
Sonir
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you run your program (the main method is invoked by the interpreter) you have at least one thread running, the "main" thread. Thus invoking Thread.yield() is perfectly legal...
HIH
[ January 21, 2002: Message edited by: Valentin Crettaz ]
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason "false" is output is that o is a reference to an object. It does not contain a null value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic