Home / Java Programming / Threads :: Discussion

Discussion :: Threads

  1. What will be the output of the program?

     public class ThreadTest extends Thread 
     {  
        public void run()   
        {        
            System.out.println("In run");          yield();    
             system.out.println("Leaving run");    
         }  
         public static void main(String []argv)    
          {     
             (new ThreadTest()).start();       
          }
       }
    

  2. A.

    The code fails to compile in the main() method

    B.

    The code fails to compile in the run() method

    C.

    Only the text "In run" will be displayed

    D.

    The text "In run" followed by "Leaving run" will be displayed

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    No answer description available for this question. Let us discuss.


Be The First To Comment