Threads - Programming

Q1:

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(); 
    } 
}

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

ANS:A - The code fails to compile in the main() method

yield() allow other Threads to execute by stopping the current Thread. Since there are no such other Threads present, therefore yield() not blocks the current Thread and execution continues after yield().