-
What is the output of this program?
class n extends Thread
{
Thread thread;
n()
{
thread = new Thread(this,"New Thread");
thread.start();
}
public void run()
{
System.out.println(thread.isAlive());
}
}
public class multithreading_Example
{
public static void main(String args[])
{
new n();
}
}
-
- Compilation Error
- True
- Runtime Error
- False
- None of these
Correct Option: B
isAlive() method is used to check whether the thread being called is running or not, here thread is the main() method which is running till the program is terminated hence it returns true.