?
What will happen when you attempt to compile and run the following code?
What will happen when you attempt to compile and run the following code?
class A implements Runnable{
public void run(){
System.out.println("run-A");
}
}
public class Test{
public static void main(String argv[]){
A a = new A();
Thread t = new Thread(a);
System.out.println(t.isAlive());
t.start();
System.out.println(t.isAlive());
}
}
class A implements Runnable{
public void run(){
System.out.println("run-A");
}
}
public class Test{
public static void main(String argv[]){
A a = new A();
Thread t = new Thread(a);
System.out.println(t.isAlive());
t.start();
System.out.println(t.isAlive());
}
}
Answer & Solution
Correct Answer:
Option
A
Once the start() method is called, the thread is considered to be alive.
Join the Discussion
Login to post a comment or share your explanation.
Loginor many more are there.