Saturday, 25 May 2013

Exception - 15 -

The thread run() method has the following code, what is the result 
when the thread runs? 
try { 
     sleep( 200 ); 
     System.out.println( "Printing from thread run() method" ); 
} catch ( IOException ie) { } 



Code :--

public class dev
{
public static void main(String a[])
{
try 

      sleep( 200 ); 
      System.out.println( "Printing from thread run() method" ); 

catch ( IOException ie) { } 
}
}

A) Compile time error 
B) Prints on the console Printing from thread run() method 
C) At line 2 the thread will be stop running and resumes after 200 milliseconds and prints "Printing from thread run() method"
D) At line 2 the thread will be stop running and resumes exactly 200 milliseconds elapsed 

No comments:

Post a Comment