This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread question from java cram Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "thread question from java cram" Watch "thread question from java cram" New topic

thread question from java cram

may leung

Joined: Nov 28, 2000
Posts: 23
You have an application that executes the following line: Thread myT = new Thread(); Select all of the following statements that are correct. [Check all correct anwers]
A) The Thread myT is now in a runnable state.
B) The Thread myT has the priority of the Thread that executed the construction statement.
C) If myT.start() is called, the run method in the class where the construction statement appears will be executed.
D) If myT.stop() is called, the Thread can later be started with myT.start() and will execute the run method in the Thread class.

The ans is B. I am not very understand what it said in B and C! can anyone explain to me?
Thanks in advance and happy new year
Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
Ans. B seems pretty clear. If you don't assign a priority to a thread it inherits the prority of the thread that created it, in this case the program thread ( I guess).
Ans. C is looking to see if you can distinguish between programs that use Runnable and those that use the Thread class to perform multi-threading. Since the thread constructor in this case doesn't take any arguments the new thread is using the run method of the thread class, if the new thread had been constructed with an object of the class in which it had been created and that class implented the Runnable interface, ques. B would have been a correct ans.
I agree. Here's the link:
subject: thread question from java cram
It's not a secret anymore!