File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread question?" Watch "Thread question?" New topic

Thread question?

Ryan Wilson
Ranch Hand

Joined: Apr 16, 2003
Posts: 65
You have an application which executes the following lines:
Thread myT = new Thread();
Select all of the following statements that are correct.
a. The Thread myT is now in a runnable state.
b. The Thread myT has the NORM_PRIORITY priority.
c. The Thread will die without accomplishing anything.
d. The run method in the class where the statement occurs will br executed.

The answers are a and c.
Could someone please explain why?
I thought all Threads are created with the normal priority (5)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
A newly created thread gets the priority of its creator.
The same goes for its deamon status.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Rory French
Ranch Hand

Joined: Apr 03, 2003
Posts: 97
I don't really agree that a is correct because of the word 'now'. Who's to say what state the thread is in 'now'. It could be runnable, running, or already dead.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
c looks right as the run method of the Thread class does nothing, so the thread will die very soon after it starts.

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Badri Sarma
Ranch Hand

Joined: Apr 01, 2003
Posts: 72
whya only a and c, why not d "The run method in the class where the statement occurs will br executed".
This statement says that if run method exists in the same class then it will execute, which is true i suppose.

Thanks<br />Badri
I agree. Here's the link:
subject: Thread question?
It's not a secret anymore!