Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

q on threads

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have an application that executes the following line:

Thread myT = new Thread();

Which statements are correct? [Check all correct answers]

The Thread myT is now in a runnable state.

The Thread myT has the priority of the Thread that executed the construction statement.

If myT.start() is called, the run method in the class where the construction statement appears will be executed.

If myT.stop() is called, the Thread can later be started with myT.start() and will execute the run method in the Thread class.

which are the correct options and y?
 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jayasiji Gopal,

I feel only the second statement is correct as, a thread inherits the priority of the parent thread.

First is false because, only when a myT.start() is called a thread enters the Runnable state. Till then, it is just a live object.

Third is false because the default "run" of the Thread class will be called.

Fourth, I am not very sure, but since stop() is deprecated, you will not get questions pertaining to stop in your SCJP1.4.

Expecting answers and demures. Thanks!

Last but not the least! As always pointed out by Barry, please always mention the link from which you get the question that you publish for us.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic