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

What will happen when you attempt to compile and run the following code?
public class Test extends Thread{
      public static void main(String argv[]){
            Test t = new Test();
            t.run();
            t.start();
      }
      public void run(){
            System.out.println("run-test");
      }
}

Answer & Solution
Correct Answer: Option A

t.run() Legal, but does not start a new thread , it is like a method call of a class Test BUT t.start() creates a thread and call run() method.

Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.