IndiaBIX.com
Arithmetic Aptitude Data Interpretation
Logical Reasoning Verbal Reasoning Non Verbal Reasoning
General Knowledge
Sudoku Number puzzles Missing letters puzzles Logical puzzles Playing cards puzzles Clock puzzles
C Programming C++ Programming C# Programming Java Programming
Microbiology Biochemistry Biotechnology Biochemical Engineering
Civil Engineering Mechanical Engineering Chemical Engineering Networking Database Questions Computer Science Basic Electronics Digital Electronics Electronic Devices Circuit Simulation Electrical Enigneering Engineering Mechanics Technical Drawing
Placement Papers Group Disucssion HR Interview Technical Interview Body Language
Aptitude Test Verbal Ability Test Verbal Reasoning Test Logical Reasoning Test C Programming Test Java Programming Test Data Interpretation Test General Knowledge Test
Data Structures Operating Systems Networking DATABASE Database Basics SQL Server Basics SQL Server Advanced SQL Server 2008 JAVA Core Java Java Basics Advanced Java UNIX Unix File Management Unix Memory Management Unix Process Managemnt C Interview Questions The C Language Basics .NET Interview Questions .NET Framework ADO.NET ASP.NET Software Testing

Java Programming - Threads - Discussion

@ : Home > Java Programming > Threads > Finding the output - Discussion

Read more:

"When ambition ends, happiness begins."
- (Proverb)
15. 

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

Answer: Option B

Explanation:

No answer description available for this question.


Manish said: (Sat, Jul 17, 2010 03:44:33 AM)    
 
Yield is a static method. It makes the currently running thread head back to the runnable state to allow other threads of same priority to get their turn, but there is no such guarantee.

Sudhansu said: (Mon, Dec 20, 2010 11:35:47 PM)    
 
yield() is a static method . Thes how we are invoking it for an instance using this.

Smith said: (Sun, Oct 9, 2011 03:29:02 PM)    
 
What is output for this program ?

Like
"In run
Leaving run"
or
like
"In run Leaving run"

Venky said: (Sun, Dec 9, 2012 05:34:03 PM)    
 
Is this possible to call super class's static method in sub class's non-static method without specifying classname(ie.yeild()).

Write your comments here:
Name *:     Email:


© 2008-2013 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!