Knowee
Questions
Features
Study Tools

Select the correct answerWhich of the following is a correct constructor for a thread object?OptionsThread(Runnable a, String str);Thread(Runnable a, ThreadGroup t);Thread(int priority);Thread(Runnable a, int priority);

Question

Select the correct answerWhich of the following is a correct constructor for a thread object?OptionsThread(Runnable a, String str);Thread(Runnable a, ThreadGroup t);Thread(int priority);Thread(Runnable a, int priority);

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct constructor for a thread object is Thread(Runnable a, String str);. This constructor creates a new thread of execution that calls the run() method on the Runnable object a, and assigns it the name str. The other constructors listed either do not exist in the Thread class or have the wrong parameter types.

Similar Questions

Select the correct answerWhat will be the output of the following Java program?class newthread implements Runnable   { Thread thr1;    newthread()     {      thr1 = new Thread(this,"My Thread");      thr1.start(); }  }  class Multithreaded_programing   {    public static void main(String args[])     {      new newthread();         }  }OptionsThread[My Thread,5,main]My ThreadCompilation ErrorRuntime Error

Select the correct answerWhich of these class is used to make a thread?OptionsSystemStringThreadRunnable

Select the correct answerWhat will be the output of the following Java program?class newthread implements Runnable   { Thread var1,var2;    newthread()     {      var1 = new Thread(this,"Thread_1");      var2 = new Thread(this,"Thread_2");      var1.start();      var2.start(); } public void run()     {      var2.setPriority(Thread.MAX_PRIORITY);   System.out.print(var1.equals(var2));    }     }  class Multithreaded_programing   {    public static void main(String args[])     {      new newthread();         }  }Optionsfalsetruetruetruefalsefalse

Select the correct answerWhat is the priority of the thread in output in the following Java program?class Main{  public static void main(String args[])  {    Thread t = Thread.currentThread();    t.setName("New Thread");    System.out.println(t.getName());       }}OptionsmainNew ThreadThread[New Thread,5,main]Thread

elect the correct answerWhat will be the output of the following Java code?class Main{  public static void main(String args[])  {    Thread t = Thread.currentThread();    t.setName("New Thread");    System.out.println(t);        }}OptionsThread[main,5,main]Thread[New Thread,5]Thread[5,main]Thread[New Thread,5,main]

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.