?
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
B. Thread(int priority)
This constructor is invalid because the
C. Thread(Runnable threadOb, String threadName)
This constructor is valid. It creates a new thread with the provided
D. Thread(String threadName, int priority)
This constructor is invalid because the
E. None of these
This option is incorrect because option C, "Thread(Runnable threadOb, String threadName)," is a valid constructor for the
Therefore, the correct answer is:
C. Thread(Runnable threadOb, String threadName)
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)
Join the Discussion
Login to post a comment or share your explanation.
Login