Java Programming - Threads - Discussion
|
|
|
|
Read more:"In the middle of difficulty lies opportunity."
- Albert Einstein
|
| 2. |
Which two are valid constructors for Thread?
- Thread(Runnable r, String name)
- Thread()
- Thread(int priority)
- Thread(Runnable r, ThreadGroup g)
- Thread(Runnable r, int priority)
|
| [A]. |
1 and 3 | [B]. |
2 and 4 | | [C]. |
1 and 2 | [D]. |
2 and 5 |
Answer: Option A
Explanation:
(1) and (2) are both valid constructors for Thread.
(3), (4), and (5) are not legal Thread constructors, although (4) is close. If you reverse the arguments in (4), you'd have a valid constructor.
|
|
Sudha said:
(Fri, May 20, 2011 12:44:26 PM)
|
|
| |
Why 4th one is wrong, what is the main raeson.
I mean wether its syntactical error or else what. |
|
Gaffney said:
(Fri, Jul 29, 2011 01:58:24 PM)
|
|
| |
| It is wrong because the order is wrong. If it were Thread (ThreadGroup g, Runnable r) then that's also a valid constructor. |
|
Ashish said:
(Tue, Jul 31, 2012 02:40:47 PM)
|
|
| |
| Why the order of the (4) constructor does matter ? |
|
|