• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

class extends thread-- shud u define run method?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Forget Steve. Look at this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic