Java Threads Aptitude Questions and Answers.
Page 2.

List of Java Threads Aptitude Questions

6) What will be the output of following program?
class ThreadEx extends Thread
{
	public void run()
	{
		Thread.sleep(100);
		System.out.println("Hello");
	}  	
	public static void main(String args[])
	{
		ThreadEx T1=new ThreadEx();
		T1.start();
	}  
}
  1. Hello [Will print instant]
  2. Hello [Will print after 100 milliseconds]
  3. HelloHelloHello... Infinite times
  4. Error

7) What will be the output of following program?
class ThreadEx extends Thread
{
	public void run()
	{
		System.out.print("Hello...");
	}
	public static void main(String args[])
	{
		ThreadEx T1=new ThreadEx();
		T1.start();
		T1.stop();
		T1.start();
	}
}
  1. Run Time Exception
  2. Compile Time Error
  3. Hello...Hello...
  4. Hello...







Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.