• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

thread

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
true or false?
a thread object has a method called notify().
1.true
2.false.
i marked false bcause this metohd is of class Object.
but they have given answer true & in explanation they told thread class inherited notify() method from Object.
even this all is true i have one question that when any exam asks which of the following methods of thread class,then what we have to do?,shall we select notify() mathod as method of thread class?
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, inherited methods are members of the class.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But do not expect such ambiguity to appear in the real exam
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thread object has a method notify(), but thread class doesn't.
Look at this question:
Which methods are belongs to Thread class?
a) start()
b) wait()
c) notify()
d) run()
e) terminate()

The correct answer is: a),d). b) & c) are belongs to object class. So, every object has b & c not every class.
Hope ur doubt is clear.
 
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i've a question here ....
Are methods inheritted by a class or an object when you say that not every class has the methods like wait() and notify() and every Object has it
 
prajkta patil
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot,
now my doubt is clear.i will not choose wait(),notify() methods as methods of thread class.
thanks again.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a distinction between which methods are "in" a class, and which methods are "declared in" a class. Methods inherited from Object are in the Thread class, although they are not declared in the Thread class.
 
Die Fledermaus does not fear such a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic