91. What will be the output of the following Java code?
class newthread extends Thread
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
public void run()
{
try
{
t.join()
System.out.println(t.getName());
}
catch(Exception e)
{
System.out.print("Exception");
}
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
class newthread extends Thread
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
public void run()
{
try
{
t.join()
System.out.println(t.getName());
}
catch(Exception e)
{
System.out.print("Exception");
}
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
92. What is the priority of the thread in the following Java Program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
System.out.println(t);
}
}
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
System.out.println(t);
}
}
93. Which of these method is used to explicitly set the priority of a thread?
94. Which of these method waits for the thread to terminate?
95. What is synchronization in reference to a thread?
96. What does not prevent JVM from terminating?
97. What is the priority of the thread in output in the following Java program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
t.setName("New Thread");
System.out.println(t.getName());
}
}
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
t.setName("New Thread");
System.out.println(t.getName());
}
}
98. Which of these method of Thread class is used to find out the priority given to a thread?
99. What is the name of the thread in the following Java Program?
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
System.out.println(t);
}
}
class multithreaded_programing
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
System.out.println(t);
}
}
100. Which function of pre defined class Thread is used to check weather current thread being checked is still running?
Read More Section(Threads)
Each Section contains maximum 100 MCQs question on Threads. To get more questions visit other sections.