No student devices needed. Know more
10 questions
What will happen if two thread of the same priority are called to be processed simultaneously?
Anyone will be executed first lexographically
Both of them will be executed simultaneously
None of them will be executed
It is dependent on the operating system
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);
} }
4
5
0
1
Deadlock is a situation when thread is waiting for other thread to release acquired object.
True
False
Which of these keywords are used to implement synchronization?
synchronize
syn
synch
synchronized
Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor?
wait()
notify()
notifyAll()
sleep()
What is synchronization in reference to a thread?
It’s a process of handling situations when two or more threads need access to a shared resource
It’s a process by which many thread are able to access same shared resource simultaneously
It’s a process by which a method is able to access many different threads simultaneously
It’s a method that allow too many threads to access any information the require
synchronized instance methods acquire lock on
object
class
all
none
What will be the output of the program?
class Test implements Runnable {
public
void run()
{
System.out.println("Run");
}
} class Myclass {
public
static void main(String[] args)
{
Thread t1 = new Thread();
t1.start();
System.out.println("Main");
}
}
Run
Main
Compile Time Error
Run Main
What will be the output of the following?
class ThreadTest extends Thread
{
public void run()
{
for(int i = 0; i < 3; i++)
{
System.out.println("A");
System.out.println("B");
}
}
}
class ThreadDemo extends Thread
{
public void run()
{
for(int i = 0; i < 3; i++)
{
System.out.println("C");
System.out.println("D");
}
}
}
public class Simple{
public static void main(String args[])
{
ThreadTest t1 = new ThreadTest();
ThreadDemo t2 = new ThreadDemo();
t1.start();
t2.start();
}
}
Will print in this order ABCD...ABCD...
Compile time Error There is no start() method.
Will print A B C D but we cannot predict the Order in which this will be printed.
Will print in this order AB CD AB...
None of these.
Which method must be defined by a class implementing the java.lang.Runnable interface?
public void start()
public void run()
void run()
None of these
Explore all questions with a free account