ExamVeda
Login
Home
This question belongs to Java Program Threads
Threads
?

Which of the following constructor of class Thread is valid one?

Answer & Solution
Correct Answer: Option C
A. Thread(Runnable threadOb, int priority)
This constructor is invalid because the Thread class does not have a constructor that takes a Runnable object and an int priority as arguments.

B. Thread(int priority)
This constructor is invalid because the Thread class does not have a constructor that takes only an int priority as an argument.

C. Thread(Runnable threadOb, String threadName)
This constructor is valid. It creates a new thread with the provided Runnable object and assigns it the specified name.

D. Thread(String threadName, int priority)
This constructor is invalid because the Thread class does not have a constructor that takes both a String thread name and an int priority as arguments.

E. None of these
This option is incorrect because option C, "Thread(Runnable threadOb, String threadName)," is a valid constructor for the Thread class.

Therefore, the correct answer is:
C. Thread(Runnable threadOb, String threadName)
Examveda
Question posted by Examveda
Community

Join the Discussion

2 Comments
Sk Aptab
Sk Aptab 3 years ago
Thread(Runnable target, String name): This constructor creates a new thread object with the specified target Runnable and the specified name.
Harsha R
Harsha R 9 years ago
How?