aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes class extends thread-- shud u define run method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "class extends thread-- shud u define run method?" Watch "class extends thread-- shud u define run method?" New topic
Author

class extends thread-- shud u define run method?

mythili sharan
Greenhorn

Joined: Sep 23, 2004
Posts: 4
This question too is from Marcus green's mock exam.
when we extend thread or implement runnable-- isnt it necessary to define the run method?? I can compile and check but what confuses me is how to tackle such a basics- shattering qn in the exam.

I thought the answer would be 1 but it is 4.



(Reformated)
[ September 24, 2004: Message edited by: Barry Gaunt ]
Tom Tolman
Ranch Hand

Joined: Sep 02, 2004
Posts: 83
If you implement Runnable, you need to define the run, since the Runnable interface has an abstract method run.

However, Thread is not an abstract class, and does implement run. It calls the Runnable if it has one, or else does nothing and returns.

Therefore, you can extend Thread and not implement run, but it won't allow you to utilize it as a separate thread, but you can utilize the class normally.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class extends thread-- shud u define run method?