aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads 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 "threads" Watch "threads" New topic
Author

threads

putti don
Greenhorn

Joined: Jul 28, 2005
Posts: 20
Hi,
Consider the following line of code :
Thread t = new Thread( anObjectOfMyClass );
Which of the following could be a valid declaration of MyClass?
1>MyClass extends Thread
2>MyClass implements Thread
3>MyClass implements Threadable
4>None of these.

the answer is option 4..My doubt is why can't it be option 1(as Thread class implements Runnable)?

Thanks.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Option 1 is valid, although it's not terribly interesting.

Compiles and runs just fine for me.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
agrah upadhyay
Ranch Hand

Joined: Sep 01, 2005
Posts: 579
But......Michael
Thread constructor don't take thread instance as argument.
As for as I know thread is having only following constructor possible:
So Option [4] should be valid...........Correct me iff i am wrong.....

Thread()

Thread(Runnable target)

Thread(Runnable target, String name)

Thread(String name)

Thread(ThreadGroup group, Runnable target)

Thread(ThreadGroup group, Runnable target, String name)

Thread(ThreadGroup group, Runnable target, String name, long stackSize)

Thread(ThreadGroup group, String name)
Jimmy Thomas
Greenhorn

Joined: Aug 17, 2005
Posts: 19
The Thread implements Runnable so it use the constructor

Thread(Runnable target)
 
jQuery in Action, 2nd edition
 
subject: threads