Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is the answer correct?

 
Kathy Cai
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
---
Which statement about Threads is NOT true?
A. Threads allow you to perform more than one task in your program at a time
B. The three elements of a thread are the CPU, the code, and the data
C. There are two ways to create a thread: extend the Thread class or implement the Runnable interface
D. Threads are faster to load, more scalable, and easier to manage than processes
---
The correct choice is C. But I do not get it. Can anyone explain? Thank you.
 
Thomas De Vos
stable boy
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thread class implements all the methods from Runnable.
If you want to create a Thread then you can either subclass the Thread class or create a new class that implements the Runnable interface.
Implementing the Runnable interface is the preferred way, it allows you to extends your own class as multiple inheritance is not supported in Java.
PS: I think when posting a question then the policy is to mention where the question came from.
[ January 13, 2004: Message edited by: Thomas De Vos ]
 
Kathy Cai
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. The question and answer were from Sun's Learning CD-ROM JAVA Programming Language.
I agree your comments. However, this means the original answer is not correct. Please note that there is "NOT" in the question. If choice "C" is not correct, which choice is correct?
 
Pedro Moreira
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stament that is NOT TRUE about Threads is:
B. The three elements of a thread are the CPU, the code, and the data
all others are correct.
 
Harvinder Singh
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which statement about Threads is NOT true?
A. Threads allow you to perform more than one task in your program at a time
B. The three elements of a thread are the CPU, the code, and the data
C. There are two ways to create a thread: extend the Thread class or implement the Runnable interface
D. Threads are faster to load, more scalable, and easier to manage than processes
A)Wrong,Threads executes a process concurrently.Such process should not have task that is comman in both the threads.Like reading from the same file
at the same time.
B)These are not the elements of the Threads. Threads is not bound to any specific CPU.
C)Obvious answer.
d)Threads are not easy to manage there are lots of things that is to be considered to successfully do it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic