Java Threads Aptitude Questions and Answers.

List of Java Threads Aptitude Questions

1) A thread can be created by using __________ class.
  1. MultiThread
  2. Thread
  3. Threading
  4. SuperThread

2) Which Java feature enables to handle multiple tasks simultaneously?
  1. Class & Object
  2. Platform Independent
  3. Dynamic Object Initialization
  4. Multi Threading

3) Which method is used to schedule a thread for execution?
  1. start()
  2. init()
  3. run()
  4. resume()

4) Consider the example and select the correct statement to start the thread.
public class ThreadEx extends Thread
{
	public void run()
	{
		System.out.println("Running...");
	}  
	
	public static void main(String args[])
	{
		ThreadEx T1=new ThreadEx();  
		__________ /*start thread*/
	}  
}  
  1. ThreadEx.start();
  2. T1.start();
  3. ThreadEx.run();
  4. T1.run();

5) What will be the output of following program?
class ThreadEx extends Thread
{
	public void run()
	{
		for(int loop=1;loop<=5;loop++)
		{
			System.out.print(loop);			
		}  
	}  	
	public static void main(String args[])
	{
		ThreadEx T1=new ThreadEx();
		ThreadEx T2=new ThreadEx();

		T1.start();
		T2.start();
	}  
}
  1. 1122334455
  2. 1234512345
  3. 1122334455... Infinite Times
  4. 1234512345... Infinite Times







Comments and Discussions!

Load comments ↻





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