Examveda
Examveda

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

A. Thread(Runnable threadOb, int priority)

B. Thread(int priority)

C. Thread(Runnable threadOb, String threadName)

D. Thread(String threadName, int priority)

E. None of these

Answer: Option C

Solution(By Examveda Team)

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)

This Question Belongs to Java Program >> Threads

Join The Discussion

Comments ( 2 )

  1. Sk Aptab
    Sk Aptab :
    9 months ago

    Thread(Runnable target, String name): This constructor creates a new thread object with the specified target Runnable and the specified name.

  2. Harsha R
    Harsha R :
    6 years ago

    How?

Related Questions on Threads

What is a thread in Java?

A. A lightweight process that runs independently within a program

B. A data structure to store variables

C. A type of loop

D. A synchronization mechanism