Home » JAVA Programming » Multithreading » Question
  1. 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();
    }
    }
    1. Compilation Error
    2. True
    3. Runtime Error
    4. False
    5. 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.



Your comments will be displayed only after manual approval.