51. What will be output of the following program code?
public class Test implements Runnable{
public void run(){
System.out.print("go");
}
public static void main(String arg[]) {
Thread t = new Thread(new Test());
t.run();
t.run();
t.start();
}
}
public class Test implements Runnable{
public void run(){
System.out.print("go");
}
public static void main(String arg[]) {
Thread t = new Thread(new Test());
t.run();
t.run();
t.start();
}
}
52. Given the code. What will be the result?
public class Test implements Runnable{
public static void main(String[] args) throws InterruptedException{
Thread a = new Thread(new Test());
a.start();
System.out.print("Begin");
a.join();
System.out.print("End");
}
public void run(){
System.out.print("Run");
}
}
public class Test implements Runnable{
public static void main(String[] args) throws InterruptedException{
Thread a = new Thread(new Test());
a.start();
System.out.print("Begin");
a.join();
System.out.print("End");
}
public void run(){
System.out.print("Run");
}
}
53. Which of this method is used to avoid polling in Java?
54. What will be the output of the following Java code?
class newthread implements Runnable
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
public void run()
{
System.out.println(t);
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
class newthread implements Runnable
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
public void run()
{
System.out.println(t);
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
55. What will be the output of the following Java code?
class newthread extends Thread
{
Thread t;
newthread()
{
t = new Thread(this,"New Thread");
t.start();
}
public void run()
{
System.out.println(t.isAlive());
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
class newthread extends Thread
{
Thread t;
newthread()
{
t = new Thread(this,"New Thread");
t.start();
}
public void run()
{
System.out.println(t.isAlive());
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
56. What will be the output of the following Java code?
class newthread extends Thread
{
Thread t1,t2;
newthread()
{
t1 = new Thread(this,"Thread_1");
t2 = new Thread(this,"Thread_2");
t1.start();
t2.start();
}
public void run()
{
t2.setPriority(Thread.MAX_PRIORITY);
System.out.print(t1.equals(t2));
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
class newthread extends Thread
{
Thread t1,t2;
newthread()
{
t1 = new Thread(this,"Thread_1");
t2 = new Thread(this,"Thread_2");
t1.start();
t2.start();
}
public void run()
{
t2.setPriority(Thread.MAX_PRIORITY);
System.out.print(t1.equals(t2));
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
57. What is true about threading?
58. What will be the output of the following Java program?
59. What will be the output of the following Java code?
class newthread implements Runnable
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
class newthread implements Runnable
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
60. What will be the output of the following Java code?
class newthread implements Runnable
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
public void run()
{
System.out.println(t.getName());
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
class newthread implements Runnable
{
Thread t;
newthread()
{
t = new Thread(this,"My Thread");
t.start();
}
public void run()
{
System.out.println(t.getName());
}
}
class multithreaded_programing
{
public static void main(String args[])
{
new newthread();
}
}
Read More Section(Threads)
Each Section contains maximum 100 MCQs question on Threads. To get more questions visit other sections.