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

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.