wood burning stoves 2.0*
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
Author

Thread Question

Daniel Liu
Greenhorn

Joined: Jul 05, 2000
Posts: 19
Question: [Check all the correct answers]
You have an application which execute the following line:
Thread myT = new Tread();
myT.start();

Select all of the crrect statements.
a. The Tread myT is now in a runnable state.
b. The Tread myT has the NORM_PRIORITY priority.
c. The Tread myT will die without accomplishing anthing.
d. The run method in the class where the statement occurs will be executed.
The answers are a and b. But why not b and d?


Daniel
Daniel Liu
Greenhorn

Joined: Jul 05, 2000
Posts: 19
Sorry, there was a typo in my original post so I it repost below.
You have an application which execute the following line:
Thread myT = new Tread();
myT.start();

Select all of the crrect statements.
a. The Tread myT is now in a runnable state.
b. The Tread myT has the NORM_PRIORITY priority.
c. The Tread myT will die without accomplishing anthing.
d. The run method in the class where the statement occurs will be executed.
The answers are a and c. But why not b and d? [/B]
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Daniel,
What you are doing is creating an instance of the Thread class, not of any of its' subclasses. Remember the run() method defined in the Thread class doesn't do anything? That's why the thread that you starts dies without accomplishing anything.
Usually we extend the Thread class or implement Runnable to provide our own implementation of the run() method. Then we create a thread from our class. But this question is perfectly valid and attempts to validate your knowledge about threads.
Beware of such questions in the exam!!
Ajith


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Aru
Ranch Hand

Joined: Jul 20, 2000
Posts: 112
Hi Ajith,
So which answers are the right ones for the question. Can you be a little more specific.
Thanks
Aruna
Daniel
Greenhorn

Joined: Dec 01, 2000
Posts: 9
What I think choice b is crrect too because the default priority value is NORM_PRIORITY
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
I think the correct answers are (a) and (c).
Daniel, I don't think the answer (b) is right. When a thread is created, it "inherits" the priority of the parent thread. Eventhough the default priority is NORM_PRIORITY, we cannot assume anything about the thread which executes the given code.
Ajith
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Question
 
Similar Threads
Thread question?
ExamCram - Threads
Threads
EXAMCRAM CD Q:TEST 2, Q 11
exam cram