Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Question from JQ+

 
Jim Hall
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following statements are true?
Select only one:
(a) To provide threading behaviour a class must extend Thread class.
(b) To provide threading behaviour a class must implement Runnable interface.
(c) Threads created by user are always non-daemon threads.
(d)Thread created internally by the JVM are always daemon threads.
(e) None of the above are correct.
I answered (b). JQ+ answer is (e).
Don't all classes that provide threading behavior implement the Runnable interface. Since the Thread class implements Runnable, isn't it correct to say the above.
[This message has been edited by Jim Hall (edited December 03, 2001).]
 
vishal avad
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i m agree with u Jim Hall
rgds
vishal
 
Rowan Brownlee
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jim,
This sounds odd. I wonder what JQ+ means by threading behaviour. eg. you might write a class (containing main) that doesn't explicitly implement Runnable, or extend Thread. However, main will execute in a thread. Would JQ+ argue that this is a provision of threading behaviour, so justifying a negative on (b)??
cheerio
rowan
Originally posted by Jim Hall:
Which of the following statements are true?
Select only one:
(a) To provide threading behaviour a class must extend Thread class.
(b) To provide threading behaviour a class must implement Runnable interface.
(c) Threads created by user are always non-daemon threads.
(d)Thread created internally by the JVM are always daemon threads.
(e) None of the above are correct.
I answered (b). JQ+ answer is (e).
Don't all classes that provide threading behavior implement the Runnable interface. Since the Thread class implements Runnable, isn't it correct to say the above.
[This message has been edited by Jim Hall (edited December 03, 2001).]

 
Jim Hall
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JQ+'s explanation says that it should be (a) and (b). That is why the answer is (e).
But can (b) be true by itself, since Thread implements Runnable.
 
farrukh mahmud
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Select only one:
(a) To provide threading behaviour a class must extend Thread class.
(b) To provide threading behaviour a class must implement Runnable interface.
(c) Threads created by user are always non-daemon threads.
(d)Thread created internally by the JVM are always daemon threads.
(e) None of the above are correct.

well first two options are correct if user want to create thread but third false and fourth true but we have to select one ans which is e
correct me if i am wrong

------------------
Regards
Farrukh Mahmud
 
Rodney Woodruff
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer lies in the wording of both a, b. d and c are false.
(a) says : To provide threading behaviour a class must extend Thread class.
Likewise (b) says To provide threading behaviour a class must implement Runnable interface.
Because both answers a and b use the word must, they are both false. These answers would be true if they said something like: To provide threading behaviour a class can either implement the Runnable interface or extend the Thread class (You could also get the behaviour by extending a class that extends the Thread class)
Therefore answers a - d would be incorrect and consequently the only correct answer is e: None of the Above are correct.
I hope this helps.

[This message has been edited by Rodney Woodruff (edited December 04, 2001).]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Rodney. BEWARE OF THE WORDING. Every word is important !!! Here we talk about "MUST" and since only one answer is accepted, clearly a and b are not correct !! e is correct.
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
angel canales
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rodney is right...
 
Hussain
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all of u read the Question carefully as it says on option b.....
b:tht it must implements Runnable..
but tht is not the case a threading Behaviour can Be provide by extending Thread as well.
Understand.
Jq+ is rite..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic