ADVERTISEMENT
ADVERTISEMENT

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...





ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.